Class: Eco::Language::BasicLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/eco/language/basic_logger.rb

Overview

Basic logger to format messaging to console

Direct Known Subclasses

API::Common::Session::Logger

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

Class Method Summary collapse

Instance Method Summary collapse

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.timestamp     = timestamp
  loggers[:console]  = ::Logger.new($stdout).tap do |logger|
    logger.formatter = format_proc(console: true)
    logger.level     = level
  end
end

Instance Attribute Details

#levelObject

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

Parameters:

  • value

    the value to set the attribute timestamp to.



19
20
21
# File 'lib/eco/language/basic_logger.rb', line 19

def timestamp=(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

Returns:

  • (Boolean)


33
34
35
# File 'lib/eco/language/basic_logger.rb', line 33

def timestamp?
  @timestamp
end