Class: Fluent::TextFormatter::GelfFormatter

Inherits:
Formatter
  • Object
show all
Includes:
GelfPluginUtil
Defined in:
lib/fluent/plugin/formatter_gelf.rb

Constant Summary

Constants included from GelfPluginUtil

GelfPluginUtil::LEVEL_MAP

Instance Method Summary collapse

Methods included from GelfPluginUtil

#make_gelfentry

Instance Method Details

#configure(conf) ⇒ Object



22
23
24
# File 'lib/fluent/plugin/formatter_gelf.rb', line 22

def configure(conf)
  super(conf)
end

#format(tag, time, record) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fluent/plugin/formatter_gelf.rb', line 26

def format(tag, time, record)
  begin
    gelfentry = make_gelfentry(
      tag, time, record,
      {
        use_record_host: @use_record_host,
        add_msec_time: @add_msec_time,
        max_bytes: @max_bytes
      }
    )

    Oj.dump(gelfentry)

  rescue Exception => e
    log.error sprintf(
      'Error trying to serialize %s: %s',
      record.to_s.force_encoding('UTF-8'),
      e.message.to_s.force_encoding('UTF-8')
    )
  end
end