# File lib/fluent/plugin/out_exec.rb, line 44 def configure(conf) super @formatter = case @format when :tsv if @keys.empty? raise ConfigError, "keys option is required on exec output for tsv format" end ExecUtil::TSVFormatter.new(@keys) when :json ExecUtil::JSONFormatter.new when :msgpack ExecUtil::MessagePackFormatter.new end if @time_key if @time_format tf = TimeFormatter.new(@time_format, @localtime) @time_format_proc = tf.method(:format) else @time_format_proc = Proc.new { |time| time.to_s } end end end
# File lib/fluent/plugin/out_exec.rb, line 69 def format(tag, time, record) out = '' if @time_key record[@time_key] = @time_format_proc.call(time) end if @tag_key record[@tag_key] = tag end @formatter.call(record, out) out end
# File lib/fluent/plugin/out_exec.rb, line 81 def write(chunk) if chunk.respond_to?(:path) prog = "#{@command} #{chunk.path}" else tmpfile = Tempfile.new("fluent-plugin-exec-") chunk.write_to(tmpfile) tmpfile.close prog = "#{@command} #{tmpfile.path}" end system(prog) ecode = $?.to_i tmpfile.delete if tmpfile if ecode != 0 raise "command returns #{ecode}: #{prog}" end end
Generated with the Darkfish Rdoc Generator 2.