Class: EcsLogging::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_logging/formatter.rb

Instance Method Summary collapse

Instance Method Details

#call(severity, time, progname, msg, **extras) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ecs_logging/formatter.rb', line 25

def call(severity, time, progname, msg, **extras)
  base = {
    "@timestamp": time.utc.iso8601(3),
    "log.level": severity,
    "message": msg,
    "ecs.version": "1.4.0"
  }

  base['log.logger'] = progname if progname

  base.merge!(extras) if extras

  JSON.fast_generate(base) + "\n"
end