TimeSlicedOutput
# File lib/fluent/plugin/out_exec.rb, line 36 def configure(conf) super @keys = @keys.split(',') 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 51 def format(tag, time, record) out = '' last = @keys.length-1 for i in 0..last key = @keys[i] if key == @time_key out << @time_format_proc.call(time) elsif key == @tag_key out << tag else out << record[key].to_s end out << "\t" if i != last end out << "\n" out end
# File lib/fluent/plugin/out_exec.rb, line 69 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.