Class: Datadog::DI::Logger Private
- Inherits:
-
Object
- Object
- Datadog::DI::Logger
- Defined in:
- lib/datadog/di/logger.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.
Logger facade to add the trace method.
Instance Attribute Summary collapse
-
#target ⇒ ::Logger
readonly
private
The target logger.
-
#trace_logging ⇒ Boolean
readonly
private
Whether trace logging is enabled.
Instance Method Summary collapse
-
#debug(message = nil, &block) ⇒ void
private
Writes the given message or the block's message to the target logger.
-
#initialize(settings, target) ⇒ Logger
constructor
private
Initializes the logger facade with the trace-logging gate resolved once.
-
#trace ⇒ void
private
Writes the block's message to the target logger at debug level when the trace-logging gate resolved at construction is enabled.
Constructor Details
#initialize(settings, target) ⇒ Logger
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.
Initializes the logger facade with the trace-logging gate resolved once. Resolving the gate at construction keeps the per-call settings traversal off the probe hot path. Components are rebuilt on reconfiguration, so the cached value tracks configuration changes.
18 19 20 21 |
# File 'lib/datadog/di/logger.rb', line 18 def initialize(settings, target) @trace_logging = settings.dynamic_instrumentation.internal.trace_logging @target = target end |
Instance Attribute Details
#target ⇒ ::Logger (readonly)
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.
The target logger.
28 29 30 |
# File 'lib/datadog/di/logger.rb', line 28 def target @target end |
#trace_logging ⇒ Boolean (readonly)
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.
Whether trace logging is enabled.
25 26 27 |
# File 'lib/datadog/di/logger.rb', line 25 def trace_logging @trace_logging end |
Instance Method Details
#debug(message = nil, &block) ⇒ void
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.
This method returns an undefined value.
Writes the given message or the block's message to the target logger.
35 36 37 38 |
# File 'lib/datadog/di/logger.rb', line 35 def debug( = nil, &block) target.debug(, &block) nil end |
#trace ⇒ void
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.
This method returns an undefined value.
Writes the block's message to the target logger at debug level when the trace-logging gate resolved at construction is enabled.
44 45 46 47 48 49 |
# File 'lib/datadog/di/logger.rb', line 44 def trace if trace_logging debug { yield } end nil end |