Class: Fluent::AddOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::AddOutput
- Defined in:
- lib/fluent/plugin/out_add.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ AddOutput
constructor
A new instance of AddOutput.
Constructor Details
#initialize ⇒ AddOutput
Returns a new instance of AddOutput.
14 15 16 |
# File 'lib/fluent/plugin/out_add.rb', line 14 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fluent/plugin/out_add.rb', line 18 def configure(conf) super @tag_prefix = "#{@add_tag_prefix}." @add_hash = Hash.new @tag_proc = if @tag_prefix Proc.new {|tag| "#{@tag_prefix}#{tag}" } else Proc.new {|tag| tag } end conf.elements.select {|element| element.name == 'pair' }.each do |pair| pair.each do | k,v| @add_hash[k] = v end end end |
#emit(tag, es, chain) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fluent/plugin/out_add.rb', line 39 def emit(tag, es, chain) emit_tag = @tag_proc.call(tag) es.each do |time,record| @add_hash.each do |k,v| record[k] = v end if @uuid record['uuid'] = SecureRandom.uuid.upcase end router.emit(emit_tag, time, record) end chain.next end |