Class: LogSinks::Filters::LoggerNamePrefixFilter
- Inherits:
-
LogSinks::Filter
- Object
- LogSinks::Filter
- LogSinks::Filters::LoggerNamePrefixFilter
- Defined in:
- lib/log_sinks/filters/logger_name_prefix_filter.rb
Overview
Filter event by logger name. Pass if logger name starts with logger prefix.
Instance Method Summary collapse
- #call(event) ⇒ Object
-
#initialize(prefix, include_root: true) ⇒ LoggerNamePrefixFilter
constructor
A new instance of LoggerNamePrefixFilter.
Constructor Details
#initialize(prefix, include_root: true) ⇒ LoggerNamePrefixFilter
Returns a new instance of LoggerNamePrefixFilter.
9 10 11 12 13 |
# File 'lib/log_sinks/filters/logger_name_prefix_filter.rb', line 9 def initialize(prefix, include_root: true) super() @prefix = prefix @include_root = include_root end |
Instance Method Details
#call(event) ⇒ Object
15 16 17 18 |
# File 'lib/log_sinks/filters/logger_name_prefix_filter.rb', line 15 def call(event) name = event.logger_name (@include_root && name == :root) || name.start_with?(@prefix) end |