Class: ProxES::Services::Logger

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/proxes/services/logger.rb

Constant Summary collapse

CONFIG =
'./config/logger.yml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



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

def initialize
  @loggers = []
  config.each do |values|
    klass = values['class'].constantize
    opts = values['options'] || nil
    logger = klass.new(opts)
    if values['level']
      logger.level = klass.const_get(values['level'].to_sym)
    end
    @loggers << logger
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



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

def method_missing(method, *args, &block)
  loggers.each { |logger| logger.send(method, *args, &block) }
end

Instance Attribute Details

#loggersObject (readonly)

Returns the value of attribute loggers.



16
17
18
# File 'lib/proxes/services/logger.rb', line 16

def loggers
  @loggers
end

Instance Method Details

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/proxes/services/logger.rb', line 35

def respond_to_missing?(method, include_private = false)
  loggers.any? { |logger| logger.respond_to?(method) }
end