Module: WscSdk::Loggable
Overview
A module that adds access to a logger.
This will check to see if a Client object is available, and use its logger otherwise it checks for an endpoint and will use its logger, as a last ditch it will build a new plain old logger that logs to STDOUT.
There is a logger attribute accessor, so you can overwrite the logger with your own.
Instance Method Summary collapse
-
#logger ⇒ Logger
Returns an instance of a logger.
-
#logger=(_logger) ⇒ Object
Sets the instance of logger.
Instance Method Details
#logger ⇒ Logger
Returns an instance of a logger.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wsc_sdk/modules/loggable.rb', line 22 def logger if @logger.nil? if self.respond_to?(:client) @logger = self.client.logger elsif self.respond_to?(:endpoint) @logger = self.endpoint.logger end @logger ||= Logger.new(STDOUT) end @logger end |
#logger=(_logger) ⇒ Object
Sets the instance of logger.
40 41 42 |
# File 'lib/wsc_sdk/modules/loggable.rb', line 40 def logger= _logger @logger = _logger end |