Class: Mu::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/mu/logger.rb

Defined Under Namespace

Classes: RubyCompatibleLogger

Constant Summary collapse

LEVELS =
%w(debug info warn error fatal).freeze

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Logger

Returns a new instance of Logger.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mu/logger.rb', line 19

def initialize(*args)
  @logger = create_logger(args)

  @logger.formatter =
    if ['colored'].include?(ENV['LOG_FORMAT'])
    then Mu::Logging::Formatting.colored_format
    else Mu::Logging::Formatting.json_format
    end

  self.level = LEVELS.index(ENV['LOG_LEVEL']) || ::Logger::INFO
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object (private)



77
78
79
# File 'lib/mu/logger.rb', line 77

def method_missing(meth, *args, &block)
  @logger.send(meth, *args, &block)
end

Instance Method Details

#for_event(event) ⇒ Object



31
32
33
# File 'lib/mu/logger.rb', line 31

def for_event(event)
  RubyCompatibleLogger.new(event, @logger)
end