Class: GreenLog::Contextualizer
- Inherits:
-
Object
- Object
- GreenLog::Contextualizer
- Includes:
- SeverityThresholdSupport
- Defined in:
- lib/green_log/contextualizer.rb
Overview
Log middleware that adds context.
Instance Attribute Summary collapse
-
#context_generator ⇒ Object
readonly
Returns the value of attribute context_generator.
-
#downstream ⇒ Object
readonly
Returns the value of attribute downstream.
Instance Method Summary collapse
- #<<(entry) ⇒ Object
-
#initialize(downstream, &context_generator) ⇒ Contextualizer
constructor
A new instance of Contextualizer.
Methods included from SeverityThresholdSupport
Constructor Details
#initialize(downstream, &context_generator) ⇒ Contextualizer
Returns a new instance of Contextualizer.
10 11 12 13 |
# File 'lib/green_log/contextualizer.rb', line 10 def initialize(downstream, &context_generator) @downstream = downstream @context_generator = context_generator end |
Instance Attribute Details
#context_generator ⇒ Object (readonly)
Returns the value of attribute context_generator.
16 17 18 |
# File 'lib/green_log/contextualizer.rb', line 16 def context_generator @context_generator end |
#downstream ⇒ Object (readonly)
Returns the value of attribute downstream.
15 16 17 |
# File 'lib/green_log/contextualizer.rb', line 15 def downstream @downstream end |
Instance Method Details
#<<(entry) ⇒ Object
18 19 20 |
# File 'lib/green_log/contextualizer.rb', line 18 def <<(entry) downstream << entry.in_context(context_generator.call) end |