Class: GemLogger::LoggerSupport::LogContextLogger
- Inherits:
-
Struct
- Object
- Struct
- GemLogger::LoggerSupport::LogContextLogger
- Includes:
- ContextLoggerCommon
- Defined in:
- lib/gem_logger/logger_support.rb
Instance Attribute Summary collapse
-
#log_context ⇒ Object
Returns the value of attribute log_context.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
Methods included from ContextLoggerCommon
#context, #event_context, #exception_context, #log_exception
Instance Attribute Details
#log_context ⇒ Object
Returns the value of attribute log_context
102 103 104 |
# File 'lib/gem_logger/logger_support.rb', line 102 def log_context @log_context end |
#logger ⇒ Object
Returns the value of attribute logger
102 103 104 |
# File 'lib/gem_logger/logger_support.rb', line 102 def logger @logger end |
Instance Method Details
#log(level, msg) ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/gem_logger/logger_support.rb', line 109 def log(level, msg) existing_context = get_context self.log_context.each { |k,v| add_to_context(k, v) } msg = format_msg_with_context(msg) self.logger.send(level, msg) ensure self.log_context.each { |k,v| remove_from_context(k) } existing_context.each { |k,v| add_to_context(k, v) } end |