Class: LogStash::Filters::Base

Inherits:
Plugin
  • Object
show all
Includes:
Config::Mixin
Defined in:
lib/logstash/filters/base.rb

Constant Summary collapse

RESERVED =
["type", "tags", "exclude_tags", "include_fields", "exclude_fields", "add_tag", "remove_tag", "add_field", "remove_field", "include_any", "exclude_any"]

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT, Config::Mixin::PLUGIN_VERSION_0_9_0, Config::Mixin::PLUGIN_VERSION_1_0_0

Constants inherited from Plugin

Plugin::NL

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #inspect, lookup, #reload, #running?, #shutdown, #terminating?, #to_s

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



134
135
136
137
138
# File 'lib/logstash/filters/base.rb', line 134

def initialize(params)
  super
  config_init(params)
  @threadsafe = true
end

Instance Method Details

#execute(event, &block) ⇒ Object



170
171
172
# File 'lib/logstash/filters/base.rb', line 170

def execute(event, &block)
  filter(event, &block)
end

#filter(event) ⇒ Object



146
147
148
# File 'lib/logstash/filters/base.rb', line 146

def filter(event)
  raise "#{self.class}#filter must be overidden"
end

#multi_filter(events) ⇒ Object



158
159
160
161
162
163
164
165
166
167
# File 'lib/logstash/filters/base.rb', line 158

def multi_filter(events)
  result = []
  events.each do |event|
    unless event.cancelled?
      result << event
      filter(event){|new_event| result << new_event}
    end
  end
  result
end

#registerObject



141
142
143
# File 'lib/logstash/filters/base.rb', line 141

def register
  raise "#{self.class}#register must be overidden"
end

#teardownObject



238
239
240
# File 'lib/logstash/filters/base.rb', line 238

def teardown
  # Nothing to do by default.
end

#threadsafe?Boolean

Returns:

  • (Boolean)


175
176
177
# File 'lib/logstash/filters/base.rb', line 175

def threadsafe?
  @threadsafe
end