Class: Eco::Language::BasicLogger
- Defined in:
- lib/eco/language/basic_logger.rb
Overview
Basic logger to format messaging to console
Direct Known Subclasses
Constant Summary collapse
- TIMESTAMP_PATTERN =
'%Y-%m-%dT%H:%M:%S'.freeze
- LOG_LEVELS =
%i[unknown fatal error warn info debug].freeze
- METHODS =
%i[<< close add].freeze
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
-
#timestamp ⇒ Object
writeonly
Sets the attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(level: ::Logger::INFO, timestamp: false) ⇒ BasicLogger
constructor
A new instance of BasicLogger.
- #timestamp? ⇒ Boolean
Constructor Details
#initialize(level: ::Logger::INFO, timestamp: false) ⇒ BasicLogger
Returns a new instance of BasicLogger.
24 25 26 27 28 29 30 31 |
# File 'lib/eco/language/basic_logger.rb', line 24 def initialize(level: ::Logger::INFO, timestamp: false) @level = level self. = loggers[:console] = ::Logger.new($stdout).tap do |logger| logger.formatter = format_proc(console: true) logger.level = level end end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
20 21 22 |
# File 'lib/eco/language/basic_logger.rb', line 20 def level @level end |
#timestamp=(value) ⇒ Object
Sets the attribute timestamp
19 20 21 |
# File 'lib/eco/language/basic_logger.rb', line 19 def (value) @timestamp = value end |
Class Method Details
.forward(*meths) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/eco/language/basic_logger.rb', line 6 def forward(*meths) meths.each do |meth| define_method(meth) do |*args, **kargs, &block| forward(meth, *args, **kargs, &block) end end end |
Instance Method Details
#timestamp? ⇒ Boolean
33 34 35 |
# File 'lib/eco/language/basic_logger.rb', line 33 def @timestamp end |