Class: ErpIntegration::Logger

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

Overview

The Logger class is a simple wrapper around the logger object.

Instance Method Summary collapse

Constructor Details

#initialize(logger = nil) ⇒ Logger

Returns a new instance of Logger.



8
9
10
# File 'lib/erp_integration/logger.rb', line 8

def initialize(logger = nil)
  @logger = logger
end

Instance Method Details

#with_tags(*tags) ⇒ Object

Logs the given tags if the logger is present. If the logger does not respond to ‘tagged`, it logs the tags as an info message.



14
15
16
17
18
19
20
21
22
23
# File 'lib/erp_integration/logger.rb', line 14

def with_tags(*tags)
  return yield unless logger

  if logger.respond_to?(:tagged)
    logger.tagged(*tags) { yield }
  else
    logger.info("Requested ERP with #{tags.join(', ')}")
    yield
  end
end