Class: NRSER::Log::Logger::Catcher

Inherits:
Object
  • Object
show all
Defined in:
lib/nrser/log/logger.rb

Overview

Class that points to a NRSER::Log::Logger and provides the log methods (#error, #warn, ... #trace) with an additional &block parameter.

Each of those methods calls the block in a begin / rescue, and if it raises, the log message will be dispatched with the raised error added.

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(logger, on_fail: nil) ⇒ Catcher

Instantiate a new Catcher.

Parameters:

  • logger (NRSER::Log::Logger)

    The logger to use if the block raises.

  • on_fail (*) (defaults to: nil)

    Value to return when &block raises.



49
50
51
52
# File 'lib/nrser/log/logger.rb', line 49

def initialize logger, on_fail: nil
  @logger = logger
  @on_fail = on_fail
end