Module: ADAL::Logging

Overview

Mix-in module for the ADAL logger. To obtain a logger in class methods the calling class will need to extend this module. To obtain a logger in instance methods the calling will need to include this Module.

Constant Summary collapse

DEFAULT_LOG_LEVEL =
Logger::ERROR
DEFAULT_LOG_OUTPUT =
STDOUT

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.correlation_idObject

Returns the value of attribute correlation_id.



42
43
44
# File 'lib/adal/logging.rb', line 42

def correlation_id
  @correlation_id
end

.log_levelObject

Returns the value of attribute log_level.



43
44
45
# File 'lib/adal/logging.rb', line 43

def log_level
  @log_level
end

.log_outputObject

Returns the value of attribute log_output.



44
45
46
# File 'lib/adal/logging.rb', line 44

def log_output
  @log_output
end

Instance Method Details

#loggerObject

Creates one ADAL logger per calling class/module with a specified output. This is to be used within ADAL. Clients will have no use for it.

Examples usage:

 require_relative './logging'

 module ADAL
   module SomeModule
     include Logging

     def something_bad
       logger.error('An error message')
     end
   end
end

Parameters:

  • output

    STDERR, STDOUT or the file name as a string.



92
93
94
95
96
# File 'lib/adal/logging.rb', line 92

def logger
  @logger ||= ADAL::Logger.new(Logging.log_output, Logging.correlation_id)
  @logger.level = Logging.log_level || DEFAULT_LOG_LEVEL
  @logger
end