Class: Ditty::Services::Logger
- Inherits:
-
Object
- Object
- Ditty::Services::Logger
- Includes:
- Singleton
- Defined in:
- lib/ditty/services/logger.rb
Overview
This is the central logger for Ditty. It can be configured to log to multiple endpoints through Ditty Settings. The default configuration is to send logs to $stdout
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.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ditty/services/logger.rb', line 20 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) logger.level = klass.const_get(values[:level].to_sym) if values[:level] @loggers << logger end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
32 33 34 |
# File 'lib/ditty/services/logger.rb', line 32 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.
18 19 20 |
# File 'lib/ditty/services/logger.rb', line 18 def loggers @loggers end |
Instance Method Details
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
36 37 38 |
# File 'lib/ditty/services/logger.rb', line 36 def respond_to_missing?(method, _include_private = false) loggers.any? { |logger| logger.respond_to?(method) } end |