Class: GreenLog::SeverityFilter
- Inherits:
-
Object
- Object
- GreenLog::SeverityFilter
- Defined in:
- lib/green_log/severity_filter.rb
Overview
Log middleware that filters by severity.
Instance Attribute Summary collapse
-
#downstream ⇒ Object
readonly
Returns the value of attribute downstream.
-
#severity_threshold ⇒ Object
readonly
Returns the value of attribute severity_threshold.
Instance Method Summary collapse
- #<<(entry) ⇒ Object
-
#initialize(downstream, threshold:) ⇒ SeverityFilter
constructor
A new instance of SeverityFilter.
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
#downstream ⇒ Object (readonly)
Returns the value of attribute downstream.
15 16 17 |
# File 'lib/green_log/severity_filter.rb', line 15 def downstream @downstream end |
#severity_threshold ⇒ Object (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 |