Class: Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp

Inherits:
Object
  • Object
show all
Includes:
EncodingHelper
Defined in:
lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb

Constant Summary collapse

EMPTY_ARRAY =
[].freeze

Constants included from EncodingHelper

EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, EncodingHelper::ESCAPED_CHARS, EncodingHelper::UNICODE_REPLACEMENT_CHARACTER

Instance Method Summary collapse

Methods included from EncodingHelper

#binary_io, #detect_binary?, #detect_encoding, #detect_libgit2_binary?, #encode!, #encode_binary, #encode_utf8, #encode_utf8_no_detect, #encode_utf8_with_replacement_character, #unquote_path

Instance Method Details

#call(severity, datetime, _, data) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb', line 11

def call(severity, datetime, _, data)
  time = data.delete :time
  data[:params] = process_params(data)

  attributes = {
    time: datetime.utc.iso8601(3),
    severity: severity,
    duration_s: Gitlab::Utils.ms_to_round_sec(time[:total]),
    db_duration_s: Gitlab::Utils.ms_to_round_sec(time[:db]),
    view_duration_s: Gitlab::Utils.ms_to_round_sec(time[:view])
  }.merge!(data)

  ::Lograge.formatter.call(attributes) << "\n"
end