Class: Logging::Filter
- Inherits:
-
Object
- Object
- Logging::Filter
- Defined in:
- lib/logging/filter.rb
Overview
The ‘Filter` class allows for filtering messages based on event properties independently of the standard minimum-level restriction.
All other Filters inherit from this class, and must override the ‘allow` method to return the event if it should be allowed into the log. Otherwise the `allow` method should return `nil`.
Direct Known Subclasses
Instance Method Summary collapse
-
#allow(event) ⇒ Object
Returns the event if it should be forwarded to the logging appender.
-
#initialize ⇒ Filter
constructor
Creates a new level filter that will pass all log events.
Constructor Details
#initialize ⇒ Filter
Creates a new level filter that will pass all log events. Create a subclass and override the ‘allow` method to filter log events.
13 14 15 |
# File 'lib/logging/filter.rb', line 13 def initialize ::Logging.init unless ::Logging.initialized? end |
Instance Method Details
#allow(event) ⇒ Object
Returns the event if it should be forwarded to the logging appender. Returns ‘nil` if the event should not be forwarded to the logging appender. Subclasses should override this method and provide their own filtering semantics.
21 22 23 |
# File 'lib/logging/filter.rb', line 21 def allow(event) event end |