Class: Lograge::Formatters::Graylog2
- Inherits:
-
Object
- Object
- Lograge::Formatters::Graylog2
- 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 17 18 19 |
# 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. data_clone = data.clone base = { short_message: (data_clone) } # Add underscore to every key to follow GELF additional field syntax. data_clone.keys.each do |key| data_clone[underscore_prefix(key)] = data_clone[key] data_clone.delete(key) end data_clone.merge(base) end |
#short_message(data) ⇒ Object
25 26 27 |
# File 'lib/lograge/formatters/graylog2.rb', line 25 def (data) "[#{data[:status]}] #{data[:method]} #{data[:path]} (#{data[:controller]}##{data[:action]})" end |
#underscore_prefix(key) ⇒ Object
21 22 23 |
# File 'lib/lograge/formatters/graylog2.rb', line 21 def underscore_prefix(key) "_#{key}".to_sym end |