Class: Fluent::ExecPlaceholderOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::ExecPlaceholderOutput
- Defined in:
- lib/fluent/plugin/out_exec_placeholder.rb
Constant Summary collapse
- PLACEHOLDER_REGEXP =
/\$\{([^}]+)\}/
- ERB_REGEXP =
"<%=record['" + '\1' + "'] %>"
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ ExecPlaceholderOutput
constructor
A new instance of ExecPlaceholderOutput.
Constructor Details
#initialize ⇒ ExecPlaceholderOutput
Returns a new instance of ExecPlaceholderOutput.
12 13 14 |
# File 'lib/fluent/plugin/out_exec_placeholder.rb', line 12 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/fluent/plugin/out_exec_placeholder.rb', line 16 def configure(conf) super command = @command.gsub('${tag}', '<%=tag %>') command = command.gsub('${time}', '<%=time %>') command = command.gsub(PLACEHOLDER_REGEXP, ERB_REGEXP) log.info(%Q{command => #{command}}) @erb = ERB.new(command) end |
#emit(tag, es, chain) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fluent/plugin/out_exec_placeholder.rb', line 29 def emit(tag, es, chain) es.each {|time, record| prog = get_prog(tag, time, record) system(prog) ecode = $?.to_i if ecode != 0 raise "command returns #{ecode}: #{prog}" end } chain.next end |
#format(tag, time, record) ⇒ Object
25 26 27 |
# File 'lib/fluent/plugin/out_exec_placeholder.rb', line 25 def format(tag, time, record) [tag, time, record].to_msgpack end |