Class: MrLogaLoga::LoggerProxy Private
- Inherits:
-
Object
- Object
- MrLogaLoga::LoggerProxy
- Extended by:
- Forwardable
- Defined in:
- lib/mr_loga_loga/logger_proxy.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Description
A proxy that attaches contextual information to the underlying logger when called.
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil, **context, &block) ⇒ Object (also: #log) private
-
#initialize(logger, context_proc) ⇒ LoggerProxy
constructor
private
A new instance of LoggerProxy.
Constructor Details
#initialize(logger, context_proc) ⇒ LoggerProxy
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of LoggerProxy.
15 16 17 18 |
# File 'lib/mr_loga_loga/logger_proxy.rb', line 15 def initialize(logger, context_proc) @logger = logger @context_proc = context_proc end |
Instance Method Details
#add(severity, message = nil, progname = nil, **context, &block) ⇒ Object Also known as: log
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 |
# File 'lib/mr_loga_loga/logger_proxy.rb', line 20 def add(severity, = nil, progname = nil, **context, &block) severity ||= UNKNOWN return true unless @logger.log?(severity) context = @context_proc.call.merge(context) @logger.add(severity, , progname, **context, &block) end |