14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/fluent/plugin/out_script_append.rb', line 14
def configure(conf)
super
ensure_param_set!(:key, @key)
ensure_param_set!(:run_script, @run_script)
ensure_param_set!("new_tag or prefix", (@new_tag or @prefix))
@script_runner = Object.new
unless SUPPORTED_SCRIPT_NAME.include? @language
warn "Plugin out_script_append would not accept 'language' value other than 'ruby'. Ignoring."
@language = 'ruby'
end
case @language
when 'ruby'
eval <<-RUBY
def @script_runner.run(#{@record_var_name})
#{@run_script}
end
RUBY
when 'sh', 'shell'
script = @run_script.gsub(/`/, '\\\`')
eval <<-RUBY
def @script_runner.run(*)
`#{@run_script}`
end
RUBY
end
end
|