Class: Lograge::Formatters::Graylog2

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

Instance Method Summary collapse

Instance Method Details

#call(data) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/lograge/formatters/graylog2.rb', line 4

def call(data)
  # Cloning because we don't want to mess with the original when mutating keys.
  my = data.clone

  base = {
    :short_message => "[#{my[:status]}] #{my[:method]} #{my[:path]} (#{my[:controller]}##{my[:action]})"
  }

  # Add underscore to every key to follow GELF additional field syntax.
  my.keys.each { |k| my["_#{k}".to_sym] = my[k]; my.delete(k) }

  my.merge(base)
end