Class: GreenLog::Contextualizer

Inherits:
Object
  • Object
show all
Includes:
SeverityThresholdSupport
Defined in:
lib/green_log/contextualizer.rb

Overview

Log middleware that adds context.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SeverityThresholdSupport

#severity_threshold

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_generatorObject (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

#downstreamObject (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