Class: Fluent::Plugin::Filter
- Defined in:
- lib/fluent/plugin/filter.rb
Direct Known Subclasses
Compat::Filter, GrepFilter, ParserFilter, RecordTransformerFilter, StdoutFilter
Constant Summary
Constants included from Configurable
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary collapse
-
#has_filter_with_time ⇒ Object
readonly
Returns the value of attribute has_filter_with_time.
Attributes included from Fluent::PluginLoggerMixin
Attributes inherited from Base
Instance Method Summary collapse
- #filter(tag, time, record) ⇒ Object
- #filter_stream(tag, es) ⇒ Object
- #filter_with_time(tag, time, record) ⇒ Object
-
#initialize ⇒ Filter
constructor
A new instance of Filter.
Methods included from Fluent::PluginHelper::Mixin
Methods included from Fluent::PluginLoggerMixin
#configure, included, #terminate
Methods included from Fluent::PluginId
#configure, #plugin_id, #plugin_id_configured?, #plugin_id_for_test?, #plugin_root_dir, #stop
Methods inherited from Base
#after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #called_in_test?, #close, #closed?, #configure, #configured?, #context_router, #context_router=, #fluentd_worker_id, #has_router?, #inspect, #multi_workers_ready?, #plugin_root_dir, #reloadable_plugin?, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?
Methods included from SystemConfig::Mixin
#system_config, #system_config_override
Methods included from Configurable
#config, #configure, #configure_proxy_generate, #configured_section_create, included, lookup_type, register_type
Constructor Details
#initialize ⇒ Filter
Returns a new instance of Filter.
35 36 37 38 |
# File 'lib/fluent/plugin/filter.rb', line 35 def initialize super @has_filter_with_time = has_filter_with_time? end |
Instance Attribute Details
#has_filter_with_time ⇒ Object (readonly)
Returns the value of attribute has_filter_with_time.
33 34 35 |
# File 'lib/fluent/plugin/filter.rb', line 33 def has_filter_with_time @has_filter_with_time end |
Instance Method Details
#filter(tag, time, record) ⇒ Object
40 41 42 |
# File 'lib/fluent/plugin/filter.rb', line 40 def filter(tag, time, record) raise NotImplementedError, "BUG: filter plugins MUST implement this method" end |
#filter_stream(tag, es) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fluent/plugin/filter.rb', line 48 def filter_stream(tag, es) new_es = MultiEventStream.new if @has_filter_with_time es.each do |time, record| begin filtered_time, filtered_record = filter_with_time(tag, time, record) new_es.add(filtered_time, filtered_record) if filtered_time && filtered_record rescue => e router.emit_error_event(tag, time, record, e) end end else es.each do |time, record| begin filtered_record = filter(tag, time, record) new_es.add(time, filtered_record) if filtered_record rescue => e router.emit_error_event(tag, time, record, e) end end end new_es end |
#filter_with_time(tag, time, record) ⇒ Object
44 45 46 |
# File 'lib/fluent/plugin/filter.rb', line 44 def filter_with_time(tag, time, record) raise NotImplementedError, "BUG: filter plugins MUST implement this method" end |