Class: Ditty::Services::Logger
- Inherits:
-
Object
- Object
- Ditty::Services::Logger
- Includes:
- Singleton
- Defined in:
- lib/ditty/services/logger.rb
Constant Summary collapse
- CONFIG =
'./config/logger.yml'.freeze
Instance Attribute Summary collapse
-
#loggers ⇒ Object
readonly
Returns the value of attribute loggers.
Instance Method Summary collapse
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to_missing?(method, _include_private = false) ⇒ Boolean
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ditty/services/logger.rb', line 16 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
29 30 31 |
# File 'lib/ditty/services/logger.rb', line 29 def method_missing(method, *args, &block) loggers.each { |logger| logger.send(method, *args, &block) } end |
Instance Attribute Details
#loggers ⇒ Object (readonly)
Returns the value of attribute loggers.
14 15 16 |
# File 'lib/ditty/services/logger.rb', line 14 def loggers @loggers end |
Instance Method Details
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
33 34 35 |
# File 'lib/ditty/services/logger.rb', line 33 def respond_to_missing?(method, _include_private = false) loggers.any? { |logger| logger.respond_to?(method) } end |