Class: EIVO::Formatter

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/eivo-rails-api/formatter.rb

Instance Method Summary collapse

Instance Method Details

#call(severity, timestamp, progname, message) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/eivo-rails-api/formatter.rb', line 8

def call(severity, timestamp, progname, message)
  json = {
    pid: $PROCESS_ID,
    level: severity,
    timestamp: timestamp.utc.iso8601(3),
    message: message
  }

  if progname
    json[:tag] = progname
  end

  if defined?(::Sidekiq)
    context = ::Sidekiq::Context.current

    if !context.empty?
      json[:context] = context
    end
  end

  MultiJson.dump(json) << "\n"
end