Class: Lograge::Formatters::Graylog2

Inherits:
Object
  • Object
show all
Includes:
Helpers::MethodAndPath
Defined in:
lib/lograge/formatters/graylog2.rb

Instance Method Summary collapse

Methods included from Helpers::MethodAndPath

#method_and_path_string

Instance Method Details

#call(data) ⇒ Object



8
9
10
11
12
13
# File 'lib/lograge/formatters/graylog2.rb', line 8

def call(data)
  # Add underscore to every key to follow GELF additional field syntax.
  data.transform_keys { |k| underscore_prefix(k) }.merge(
    short_message: short_message(data)
  )
end

#short_message(data) ⇒ Object



19
20
21
# File 'lib/lograge/formatters/graylog2.rb', line 19

def short_message(data)
  "[#{data[:status]}]#{method_and_path_string(data)}(#{data[:controller]}##{data[:action]})"
end

#underscore_prefix(key) ⇒ Object



15
16
17
# File 'lib/lograge/formatters/graylog2.rb', line 15

def underscore_prefix(key)
  "_#{key}".to_sym
end