debian-mirror-gitlab/lib/gitlab/json_logger.rb

26 lines
559 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2018-11-18 11:00:15 +05:30
module Gitlab
class JsonLogger < ::Gitlab::Logger
def self.file_name_noext
raise NotImplementedError
end
def format_message(severity, timestamp, progname, message)
data = {}
data[:severity] = severity
data[:time] = timestamp.utc.iso8601(3)
2019-02-13 22:33:31 +05:30
data[Gitlab::CorrelationId::LOG_KEY] = Gitlab::CorrelationId.current_id
2018-11-18 11:00:15 +05:30
case message
when String
data[:message] = message
when Hash
data.merge!(message)
end
data.to_json + "\n"
end
end
end