Class: ADAL::Logger
- Inherits:
-
Logger
- Object
- Logger
- ADAL::Logger
- Defined in:
- lib/adal/logger.rb
Overview
Extended version of Ruby’s base logger class to support VERBOSE logging. This is consistent with ADAL logging across platforms.
The format of a log message is described in the Ruby docs at ruby-doc.org/stdlib-2.2.2/libdoc/logger/rdoc/Logger.html as SeverityID, [DateTime #pid] SeverityLabel – ProgName: message. SeverityID is the first letter of the severity. In the case of ADAL::Logger that means one of I, W, E, F. The DateTime object uses the to_s method of DateTime from stdlib which is ISO-8601. The ProgName will be the correlation id if one is sent or absent otherwise.
Constant Summary collapse
- SEVS =
%w(VERBOSE INFO WARN ERROR FATAL)
- VERBOSE =
SEVS.index('VERBOSE')
Instance Method Summary collapse
-
#error(message = nil, &block) ⇒ Object
:nocov:.
- #fatal(message = nil, &block) ⇒ Object
- #format_severity(severity) ⇒ Object
- #info(message = nil, &block) ⇒ Object
-
#initialize(logdev, correlation_id) ⇒ Logger
constructor
Constructs a new Logger.
- #verbose(message = nil, &block) ⇒ Object
- #warn(message = nil, &block) ⇒ Object
Constructor Details
#initialize(logdev, correlation_id) ⇒ Logger
Constructs a new Logger.
47 48 49 50 |
# File 'lib/adal/logger.rb', line 47 def initialize(logdev, correlation_id) super(logdev) @correlation_id = correlation_id end |
Instance Method Details
#error(message = nil, &block) ⇒ Object
:nocov:
69 70 71 |
# File 'lib/adal/logger.rb', line 69 def error( = nil, &block) add(ERROR, , @correlation_id, &block) end |
#fatal(message = nil, &block) ⇒ Object
73 74 75 |
# File 'lib/adal/logger.rb', line 73 def fatal( = nil, &block) add(FATAL, , @correlation_id, &block) end |
#format_severity(severity) ⇒ Object
52 53 54 |
# File 'lib/adal/logger.rb', line 52 def format_severity(severity) SEVS[severity] || 'ANY' end |
#info(message = nil, &block) ⇒ Object
77 78 79 |
# File 'lib/adal/logger.rb', line 77 def info( = nil, &block) add(INFO, , @correlation_id, &block) end |
#verbose(message = nil, &block) ⇒ Object
81 82 83 |
# File 'lib/adal/logger.rb', line 81 def verbose( = nil, &block) add(VERBOSE, , @correlation_id, &block) end |
#warn(message = nil, &block) ⇒ Object
85 86 87 |
# File 'lib/adal/logger.rb', line 85 def warn( = nil, &block) add(WARN, , @correlation_id, &block) end |