Class: Sawmill::EntryProcessor::FilterByBasicFields

Inherits:
Base
  • Object
show all
Defined in:
lib/sawmill/entry_processor/filter_by_basic_fields.rb

Overview

A basic filter that knows how to check level and progname.

This is a boolean processor, so it merely returns true or false based on the filter result. Use this in conjunction with an If processor to actually perform other actions based on the result.

Instance Method Summary collapse

Methods inherited from Base

add_dsl_method, inherited

Constructor Details

#initialize(opts_ = {}) ⇒ FilterByBasicFields

Create a new filter.

Recognized options include:

:level

Lowest level that will be accepted. This should be either a Sawmill::Level object or an integer value or string/symbol that represents a level. If set to nil or not specified, this filter does not check the level.

:progname

Progname filter. This can be either a string or a Regexp. If set to nil or not specified, this filter does not check the progname.

:accept_record_delimiters

If set to true, accepts all begin_record and end_record entries regardless of the level or progname. If set to false, accepts no such entries. Otherwise, if not specified, those entries are subject to the usual level and progname filters.

:accept_attributes

If set to true, accepts all attribute and multi_attribute entries regardless of the level or progname. If set to false, accepts no such entries. Otherwise, if not specified, those entries are subject to the usual level and progname filters.

:accept_incomparable_levels

If set to true, accepts entries whose level is not comparable to the given :level setting. Otherwise, rejects all such entries.

:accept_unknown

If set to true, accepts all entries of type :unknown_data. Otherwise, rejects all such entries.



81
82
83
84
85
86
87
88
# File 'lib/sawmill/entry_processor/filter_by_basic_fields.rb', line 81

def initialize(opts_={})
  @level = opts_[:level]
  @progname = opts_[:progname]
  @accept_record_delimiters = opts_[:accept_record_delimiters]
  @accept_attributes = opts_[:accept_attributes]
  @accept_incomparable_levels = opts_[:accept_incomparable_levels]
  @accept_unknown = opts_[:accept_unknown]
end

Instance Method Details

#attribute(entry_) ⇒ Object



103
104
105
# File 'lib/sawmill/entry_processor/filter_by_basic_fields.rb', line 103

def attribute(entry_)
  @accept_attributes.nil? ? _check_filter(entry_) : @accept_attributes
end

#begin_record(entry_) ⇒ Object



91
92
93
# File 'lib/sawmill/entry_processor/filter_by_basic_fields.rb', line 91

def begin_record(entry_)
  @accept_record_delimiters.nil? ? _check_filter(entry_) : @accept_record_delimiters
end

#end_record(entry_) ⇒ Object



95
96
97
# File 'lib/sawmill/entry_processor/filter_by_basic_fields.rb', line 95

def end_record(entry_)
  @accept_record_delimiters.nil? ? _check_filter(entry_) : @accept_record_delimiters
end

#finishObject



111
112
113
# File 'lib/sawmill/entry_processor/filter_by_basic_fields.rb', line 111

def finish
  nil
end

#message(entry_) ⇒ Object



99
100
101
# File 'lib/sawmill/entry_processor/filter_by_basic_fields.rb', line 99

def message(entry_)
  _check_filter(entry_)
end

#unknown_data(entry_) ⇒ Object



107
108
109
# File 'lib/sawmill/entry_processor/filter_by_basic_fields.rb', line 107

def unknown_data(entry_)
  @accept_unknown
end