Class: Lograge::Formatters::Logstash

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

Instance Method Summary collapse

Instance Method Details

#call(data) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/lograge/formatters/logstash.rb', line 4

def call(data)
  load_dependencies
  event = LogStash::Event.new(data)

  event.message = "[#{data[:status]}] #{data[:method]} #{data[:path]} (#{data[:controller]}##{data[:action]})"
  event.to_json
end

#load_dependenciesObject



12
13
14
15
16
17
# File 'lib/lograge/formatters/logstash.rb', line 12

def load_dependencies
  require 'logstash-event'
rescue LoadError
  puts 'You need to install the logstash-event gem to use the logstash output.'
  raise
end