Class: Sidekiq::Tracer::JsonLogFormatter

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/sidekiq/tracer/json_log_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(pretty: false) ⇒ JsonLogFormatter

Returns a new instance of JsonLogFormatter.



6
7
8
# File 'lib/sidekiq/tracer/json_log_formatter.rb', line 6

def initialize(pretty: false)
  @pretty = !!pretty
end

Instance Method Details

#call(severity, time, _progname, msg) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sidekiq/tracer/json_log_formatter.rb', line 10

def call(severity, time, _progname, msg)
  MultiJson.dump({
    tms: time.utc.iso8601(3),
    pid: pid,
    tid: format("TID-%s", thread_id),
    cxt: context,
    sev: severity,
    msg: msg,
    trc: trace,
  }, pretty: @pretty) + "\n"
end