Class: Ditty::Services::Logger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



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

def initialize
  @loggers = []
  return if config[:loggers].blank?
  config[:loggers].each do |values|
    klass = values[:class].constantize
    opts = tr(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/ditty/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.



15
16
17
# File 'lib/ditty/services/logger.rb', line 15

def loggers
  @loggers
end

Instance Method Details

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

Returns:

  • (Boolean)


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

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