Class: LogStash::Filters::Base

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

Constant Summary

Constants included from Config::Mixin

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

Constants included from Util::SubstitutionVariables

Util::SubstitutionVariables::SUBSTITUTION_PLACEHOLDER_REGEX

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Config::Mixin

#config_init, included

Methods included from Util::SubstitutionVariables

#deep_replace, #replace_placeholders

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



124
125
126
127
128
# File 'lib/logstash/filters/base.rb', line 124

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

Class Method Details

.plugin_typeObject



119
120
121
# File 'lib/logstash/filters/base.rb', line 119

def self.plugin_type
  "filter"
end

Instance Method Details

#closeObject



221
222
223
# File 'lib/logstash/filters/base.rb', line 221

def close
  # Nothing to do by default.
end

#do_filter(event, &block) ⇒ Object



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

def do_filter(event, &block)
  time = java.lang.System.nanoTime
  filter(event, &block)
  @slow_logger.on_event("event processing time", @original_params, event, java.lang.System.nanoTime - time)
end

#execute(event, &block) ⇒ Object



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

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

#filter(event) ⇒ Object



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

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

#multi_filter(events) ⇒ Object



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

def multi_filter(events)
  LogStash::Util.set_thread_plugin(self)
  result = []
  events.each do |event|
    unless event.cancelled?
      result << event
      do_filter(event){|new_event| result << new_event}
    end
  end
  result
end

#registerObject



131
132
133
# File 'lib/logstash/filters/base.rb', line 131

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

#threadsafe?Boolean

Returns:

  • (Boolean)


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

def threadsafe?
  @threadsafe
end