Class: Fluent::RawExecOutput
- Inherits:
-
TimeSlicedOutput
- Object
- TimeSlicedOutput
- Fluent::RawExecOutput
- Defined in:
- lib/fluent/plugin/out_rawexec.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ RawExecOutput
constructor
A new instance of RawExecOutput.
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ RawExecOutput
Returns a new instance of RawExecOutput.
22 23 24 25 26 |
# File 'lib/fluent/plugin/out_rawexec.rb', line 22 def initialize super require 'tempfile' @localtime = false end |
Instance Method Details
#configure(conf) ⇒ Object
31 32 33 |
# File 'lib/fluent/plugin/out_rawexec.rb', line 31 def configure(conf) super end |
#format(tag, time, record) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/out_rawexec.rb', line 35 def format(tag, time, record) if @tag record.merge!(@tag => tag) end out = '' out << record.to_s out << "\n" out end |
#write(chunk) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fluent/plugin/out_rawexec.rb', line 45 def write(chunk) if chunk.respond_to?(:path) prog = "#{@command} #{chunk.path}" else tmpfile = Tempfile.new("fluent-plugin-rawexec-") 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 |