Class: Fluent::Plugin::ScriptFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_script.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



9
10
11
12
# File 'lib/fluent/plugin/filter_script.rb', line 9

def configure(conf)
  super
  load_script_file(conf['path'].to_s)
end

#filter(tag, time, record) ⇒ Object



19
20
21
# File 'lib/fluent/plugin/filter_script.rb', line 19

def filter(tag, time, record)
  # Overwritten by evaluated script.
end

#load_script_file(path) ⇒ Object

Raises:

  • (Fluent::ConfigError)


14
15
16
17
# File 'lib/fluent/plugin/filter_script.rb', line 14

def load_script_file(path)
  raise Fluent::ConfigError, "Ruby script file does not exist: #{path}" unless File.exist?(path)
  eval "self.instance_eval do;" + IO.read(path) + ";\nend"
end