Class: Lorekeeper::SimpleLogger
- Inherits:
-
FastLogger
- Object
- FastLogger
- Lorekeeper::SimpleLogger
- Defined in:
- lib/lorekeeper/simple_logger.rb
Overview
Simple logger provides a logger which outputs messages in a colorized simple text format.
Constant Summary collapse
- SEVERITY_TO_COLOR_MAP =
From http://misc.flogisoft.com/bash/tip_colors_and_formatting 39: default for the theme 33: yellow 31: red 37: light gray
{ DEBUG => '39'.freeze, INFO => DEBUG, WARN => '33'.freeze, ERROR => '31'.freeze, FATAL => ERROR, UNKNOWN => '37'.freeze }.freeze
Constants inherited from FastLogger
FastLogger::LOGGING_METHODS, FastLogger::METHOD_SEVERITY_MAP
Instance Attribute Summary
Attributes inherited from FastLogger
Instance Method Summary collapse
- #exception(exception, custom_message = nil, custom_data = nil) ⇒ Object
- #inspect ⇒ Object
-
#log_data(severity, message) ⇒ Object
\e[colorm sets a color \e[0m resets all properties.
Methods inherited from FastLogger
#add, #debug?, #error?, #fatal?, #info?, #initialize, #silence_logger, #warn?
Constructor Details
This class inherits a constructor from Lorekeeper::FastLogger
Instance Method Details
#exception(exception, custom_message = nil, custom_data = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lorekeeper/simple_logger.rb', line 40 def exception(exception, = nil, custom_data = nil) if exception.is_a?(Exception) backtrace = exception.backtrace || [] = || exception. error_with_data("#{exception.class}: #{}", backtrace.join("\n")) else log_data(:warning, 'Logger exception called without exception class.') error_with_data("#{exception.class}: #{exception.inspect} #{}", custom_data) end end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/lorekeeper/simple_logger.rb', line 28 def inspect "Lorekeeper Simple logger. IO: #{@file.inspect}" end |
#log_data(severity, message) ⇒ Object
\e[colorm sets a color \e[0m resets all properties
23 24 25 26 |
# File 'lib/lorekeeper/simple_logger.rb', line 23 def log_data(severity, ) color = SEVERITY_TO_COLOR_MAP[severity] @iodevice.write("\e[#{color}m#{}\e[0m\n") end |