module ADAL::Logging
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.
Constants
- DEFAULT_LOG_LEVEL
- DEFAULT_LOG_OUTPUT
Attributes
correlation_id[RW]
log_level[RW]
log_output[RW]
Public Class Methods
log_level=(level)
click to toggle source
Sets the ADAL
log level.
Example usage:
ADAL::Logging.log_level = ADAL::Logger::VERBOSE
# File lib/adal/logging.rb, line 54 def self.log_level=(level) unless Logger::SEVS.map.with_index { |_, i| i }.include? level fail ArgumentError, "Invalid log level: #{level}." end @log_level = level end
log_output=(output)
click to toggle source
Sets the ADAL
log output. All future logs generated by ADAL
will be sent to this location. It is not retroactive.
@param IO|String output
This can either be STDERR, STDOUT or a String containing a file path.
# File lib/adal/logging.rb, line 67 def self.log_output=(output) output = output.to_s unless output.is_a? IO @log_output = output end
Public Instance Methods
logger()
click to toggle source
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
@param output
STDERR, STDOUT or the file name as a string.
# 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