class GreenLog::SeverityFilter

Log middleware that filters by severity.

Attributes

downstream[R]
severity_threshold[R]

Public Class Methods

new(downstream, threshold:) click to toggle source
# File lib/green_log/severity_filter.rb, line 10
def initialize(downstream, threshold:)
  @downstream = downstream
  @severity_threshold = GreenLog::Severity.resolve(threshold)
end

Public Instance Methods

<<(entry) click to toggle source
# File lib/green_log/severity_filter.rb, line 18
def <<(entry)
  return if entry.severity < severity_threshold

  downstream << entry
end