Class: GreenLog::SeverityFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/green_log/severity_filter.rb

Overview

Log middleware that filters by severity.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(downstream, threshold:) ⇒ SeverityFilter

Returns a new instance of SeverityFilter.



10
11
12
13
# File 'lib/green_log/severity_filter.rb', line 10

def initialize(downstream, threshold:)
  @downstream = downstream
  @severity_threshold = GreenLog::Severity.resolve(threshold)
end

Instance Attribute Details

#downstreamObject (readonly)

Returns the value of attribute downstream.



15
16
17
# File 'lib/green_log/severity_filter.rb', line 15

def downstream
  @downstream
end

#severity_thresholdObject (readonly)

Returns the value of attribute severity_threshold.



16
17
18
# File 'lib/green_log/severity_filter.rb', line 16

def severity_threshold
  @severity_threshold
end

Instance Method Details

#<<(entry) ⇒ Object



18
19
20
21
22
# File 'lib/green_log/severity_filter.rb', line 18

def <<(entry)
  return if entry.severity < severity_threshold

  downstream << entry
end