Module: Lumberjack::Rails::TaggedForkedLogger
- Defined in:
- lib/lumberjack/rails/tagged_forked_logger.rb
Overview
Extension for Lumberjack::ForkedLogger to support ActiveSupport tagged logging.
This module adds tagged logging capabilities to forked loggers by delegating tagged calls to the parent logger when available. It also shares the ActiveSupport local log level (used by silence and log_at) with the parent logger so that silencing the parent silences the fork.
Instance Method Summary collapse
-
#local_level ⇒ Integer?
Get the local log level from the parent logger so that silence and log_at on the parent apply to log entries written through the forked logger.
-
#local_level=(value) ⇒ void
Set the local log level on the parent logger.
-
#tagged(*tags) { ... } ⇒ Object
Execute a block with the specified tags if the parent logger supports tagging.
Instance Method Details
#local_level ⇒ Integer?
Get the local log level from the parent logger so that silence and log_at on the parent apply to log entries written through the forked logger.
33 34 35 |
# File 'lib/lumberjack/rails/tagged_forked_logger.rb', line 33 def local_level parent_logger.respond_to?(:local_level) ? parent_logger.local_level : super end |
#local_level=(value) ⇒ void
This method returns an undefined value.
Set the local log level on the parent logger.
41 42 43 44 45 46 47 |
# File 'lib/lumberjack/rails/tagged_forked_logger.rb', line 41 def local_level=(value) if parent_logger.respond_to?(:local_level=) parent_logger.local_level = value else super end end |
#tagged(*tags) { ... } ⇒ Object
Execute a block with the specified tags if the parent logger supports tagging. If the parent logger does not support tagging, the block is still executed without any tags applied.
19 20 21 22 23 24 25 26 27 |
# File 'lib/lumberjack/rails/tagged_forked_logger.rb', line 19 def tagged(*, &block) if parent_logger.respond_to?(:tagged) parent_logger.tagged(*, &block) elsif block block.call else self end end |