debian-mirror-gitlab/lib/gitlab/sidekiq_logging/json_formatter.rb
2018-12-23 12:14:25 +05:30

23 lines
437 B
Ruby

# frozen_string_literal: true
module Gitlab
module SidekiqLogging
class JSONFormatter
def call(severity, timestamp, progname, data)
output = {
severity: severity,
time: timestamp.utc.iso8601(3)
}
case data
when String
output[:message] = data
when Hash
output.merge!(data)
end
output.to_json + "\n"
end
end
end
end