Module: LB::Operation::Log

Included in:
LB::Operation
Defined in:
lib/lb/operation/log.rb

Overview

Helper for logging

Defined Under Namespace

Modules: ClassInterface

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Extends base class with class interface.

Parameters:

  • base (Class)

Returns:

  • (Object)

25
26
27
# File 'lib/lb/operation/log.rb', line 25

def self.included(base)
  base.extend ClassInterface
end

Instance Method Details

#log(method, *args) ⇒ Object

Calls given logger method with given arguments.

Parameters:

  • method (Symbol)
  • args (Array)

Returns:

  • (Object)

48
49
50
51
52
53
# File 'lib/lb/operation/log.rb', line 48

def log(method, *args)
  unless logger.respond_to?(method)
    raise ArgumentError, "Logger does not respond to :#{method}."
  end
  logger.public_send(method, *args)
end

#loggerObject

Retrieves the logger.

Returns:

  • (Object)

32
33
34
35
36
37
38
39
40
41
# File 'lib/lb/operation/log.rb', line 32

def logger
  result = self.class.logger
  if result.nil?
    raise ArgumentError,
          'No logger availible: Please set logger via '\
          'LB::Operation::Log[logger] or '\
          'LB::Operation::Log.with_logger(logger)'
  end
  result
end