Class: CemAcpt::Logging::MultiLogger
- Inherits:
-
Object
- Object
- CemAcpt::Logging::MultiLogger
- Defined in:
- lib/cem_acpt/logging.rb
Overview
Delegator class for when you want to log to multiple devices at the same time, such as STDOUT and a file.
Instance Method Summary collapse
-
#initialize(*loggers) ⇒ MultiLogger
constructor
A new instance of MultiLogger.
- #method_missing(m, *args, &block) ⇒ Object
- #respond_to_missing?(m, include_private = false) ⇒ Boolean
Constructor Details
#initialize(*loggers) ⇒ MultiLogger
Returns a new instance of MultiLogger.
21 22 23 |
# File 'lib/cem_acpt/logging.rb', line 21 def initialize(*loggers) @loggers = loggers end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/cem_acpt/logging.rb', line 25 def method_missing(m, *args, &block) if @loggers.all? { |l| l.respond_to?(m) } @loggers.map { |l| l.send(m, *args, &block) } else super end end |
Instance Method Details
#respond_to_missing?(m, include_private = false) ⇒ Boolean
33 34 35 |
# File 'lib/cem_acpt/logging.rb', line 33 def respond_to_missing?(m, include_private = false) @loggers.all? { |l| l.respond_to?(m) } || super end |