Class: Maze::Loggers::STDOUTLogger
- Includes:
- Singleton
- Defined in:
- lib/maze/loggers/stdout_logger.rb
Overview
A logger to STDOUT, with level configured according to the environment
Instance Attribute Summary collapse
-
#datetime_format ⇒ Object
Returns the value of attribute datetime_format.
Attributes inherited from Logger
Instance Method Summary collapse
-
#initialize ⇒ STDOUTLogger
constructor
A new instance of STDOUTLogger.
Methods inherited from Logger
Constructor Details
#initialize ⇒ STDOUTLogger
Returns a new instance of STDOUTLogger.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/maze/loggers/stdout_logger.rb', line 13 def initialize if ENV['TRACE'] super(STDOUT, level: ::Logger::TRACE) elsif ENV['DEBUG'] super(STDOUT, level: ::Logger::DEBUG) elsif ENV['QUIET'] super(STDOUT, level: ::Logger::ERROR) else super(STDOUT, level: ::Logger::INFO) end @datetime_format = '%H:%M:%S' @formatter = proc do |severity, time, _name, | formatted_time = time.strftime(@datetime_format) "\e[2m[#{formatted_time}]\e[0m #{severity.rjust(5)}: #{}\n" end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Maze::Loggers::Logger
Instance Attribute Details
#datetime_format ⇒ Object
Returns the value of attribute datetime_format.
11 12 13 |
# File 'lib/maze/loggers/stdout_logger.rb', line 11 def datetime_format @datetime_format end |