Class: Fluent::Timestamper

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_timestamper.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



9
10
11
# File 'lib/fluent/plugin/out_timestamper.rb', line 9

def configure(conf)
  super
end

#emit(tag, es, chain) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fluent/plugin/out_timestamper.rb', line 13

def emit(tag, es, chain)
  now = Time.now

  es.each do |time, record|
    case @format
    when "seconds"
      record[@key] = now.to_i
    when "milliseconds"
      record[@key] = (now.to_i * 1000) + (now.usec / 1000.0).round
    when "iso8601"
      record[@key] = now.iso8601
    else
      record[@key] = now.strftime(@format)
    end

    Fluent::Engine.emit(@tag, time, record)
  end

  chain.next
end