Module: Fluent::FilterWhere::Core

Included in:
PluginFilterWhere, Plugin::FilterWhere
Defined in:
lib/fluent/plugin/filter_where/core.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



10
11
12
# File 'lib/fluent/plugin/filter_where/core.rb', line 10

def self.included(klass)
  klass.config_param :where, :string, :desc => 'The SQL-like WHERE statement.'
end

Instance Method Details

#configure(conf) ⇒ Object



14
15
16
17
18
19
# File 'lib/fluent/plugin/filter_where/core.rb', line 14

def configure(conf)
  super

  parser = Fluent::FilterWhere::Parser.new(log: log)
  @scanner = parser.scan(@where)
end

#filter(tag, time, record) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/fluent/plugin/filter_where/core.rb', line 21

def filter(tag, time, record)
  if @scanner.eval(record)
    record
  else
    nil # remove
  end
rescue => e
  log.warn "filter_where: #{e.class} #{e.message} #{e.backtrace.first}"
  log.debug "filter_where:: tag:#{tag} time:#{time} record:#{record}"
end

#initializeObject



6
7
8
# File 'lib/fluent/plugin/filter_where/core.rb', line 6

def initialize
  super
end