Class: CemWinSpec::Logging::MultiLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/cem_win_spec/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

Constructor Details

#initialize(*loggers) ⇒ MultiLogger

Returns a new instance of MultiLogger.



22
23
24
# File 'lib/cem_win_spec/logging.rb', line 22

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



26
27
28
29
30
31
32
# File 'lib/cem_win_spec/logging.rb', line 26

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

Returns:

  • (Boolean)


34
35
36
# File 'lib/cem_win_spec/logging.rb', line 34

def respond_to_missing?(m, include_private = false)
  @loggers.all? { |l| l.respond_to?(m) } || super
end