class Fluent::ScriptAppendOutput
Constants
- SUPPORTED_SCRIPT_NAME
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# 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
emit(tag, event_stream, chain)
click to toggle source
# File lib/fluent/plugin/out_script_append.rb, line 44 def emit(tag, event_stream, chain) event_stream.each do |time, record| rewrited_tag = get_new_tag(tag) record[@key] = @script_runner.run(record) Fluent::Engine.emit(rewrited_tag, time, record) end chain.next end
Private Instance Methods
ensure_param_set!(name, value)
click to toggle source
# File lib/fluent/plugin/out_script_append.rb, line 62 def ensure_param_set!(name, value) unless value raise Fluent::ConfigError, "#{name} must be set" end end
get_new_tag(tag)
click to toggle source
# File lib/fluent/plugin/out_script_append.rb, line 54 def get_new_tag(tag) if @new_tag @new_tag elsif @prefix [@prefix, tag].join('.') end end