Class: Wurk::Logger::Formatters::JSON

Inherits:
Base
  • Object
show all
Defined in:
lib/wurk/logger.rb

Constant Summary

Constants inherited from Base

Base::SEVERITY_COLORS

Instance Method Summary collapse

Methods inherited from Base

#format_context, #tid

Instance Method Details

#call(severity, time, _program_name, message) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/wurk/logger.rb', line 55

def call(severity, time, _program_name, message)
  hash = {
    ts: time.utc.iso8601(3),
    pid: ::Process.pid,
    tid: tid,
    lvl: severity,
    msg: message
  }
  ctx = Wurk::Context.current
  hash[:ctx] = ctx unless ctx.empty?
  "#{::JSON.generate(hash)}\n"
end