Class: Logging::Filters::Level
- Inherits:
-
Logging::Filter
- Object
- Logging::Filter
- Logging::Filters::Level
- Defined in:
- lib/logging/filters/level.rb
Overview
The ‘Level` filter class provides a simple level-based filtering mechanism that filters messages to only include those from an enumerated list of levels to log.
Instance Method Summary collapse
- #allow(event) ⇒ Object
-
#initialize(*levels) ⇒ Level
constructor
Creates a new level filter that will only allow the given levels to propagate through to the logging destination.
Constructor Details
#initialize(*levels) ⇒ Level
Creates a new level filter that will only allow the given levels to propagate through to the logging destination. The levels should be given in symbolic form.
Examples
Logging::Filters::Level.new(:debug, :info)
18 19 20 21 |
# File 'lib/logging/filters/level.rb', line 18 def initialize( *levels ) levels = levels.map { |level| ::Logging::level_num(level) } @levels = Set.new levels end |
Instance Method Details
#allow(event) ⇒ Object
23 24 25 |
# File 'lib/logging/filters/level.rb', line 23 def allow( event ) @levels.include?(event.level) ? event : nil end |