Class: Log::Dispatcher
- Inherits:
-
Object
- Object
- Log::Dispatcher
- Defined in:
- lib/log/dispatcher.rb
Instance Attribute Summary collapse
-
#raise_on_log_failure ⇒ Object
Returns the value of attribute raise_on_log_failure.
Class Method Summary collapse
Instance Method Summary collapse
- #dispatch(severity, message, context = {}, events = []) ⇒ Object
-
#initialize(loggers) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
Constructor Details
#initialize(loggers) ⇒ Dispatcher
Returns a new instance of Dispatcher.
11 12 13 14 |
# File 'lib/log/dispatcher.rb', line 11 def initialize(loggers) Dispatcher.verify_loggers(config.loggers) @loggers = loggers end |
Instance Attribute Details
#raise_on_log_failure ⇒ Object
Returns the value of attribute raise_on_log_failure.
5 6 7 |
# File 'lib/log/dispatcher.rb', line 5 def raise_on_log_failure @raise_on_log_failure end |
Class Method Details
.dispatch(severity, message, context = {}, events = []) ⇒ Object
7 8 9 |
# File 'lib/log/dispatcher.rb', line 7 def self.dispatch(severity, , context = {}, events = []) Dispatcher.new(Log.config.loggers).dispatch(severity, , context, events) end |
Instance Method Details
#dispatch(severity, message, context = {}, events = []) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/log/dispatcher.rb', line 16 def dispatch(severity, , context={}, events=[]) raise ArgumentError.new("context must be Hash") unless context.kind_of?(Hash) failed_loggers = {} = {} @loggers.each do |logger| begin result = logger.log(severity, , context, events, ) .merge!(result) if (result.kind_of?(Hash)) rescue => e failed_loggers[logger.name] = e end end handle_failed_loggers(failed_loggers) end |