Sha256: c884487a8cd4dd98e7e1eb52360b4244f9b22f9dadf78371740c41ef4f6b1766

Contents?: true

Size: 566 Bytes

Versions: 3

Compression:

Stored size: 566 Bytes

Contents

module Lograge
  module Formatters
    class Logstash
      include Lograge::Formatters::Helpers::MethodAndPath

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lograge-0.11.2 lib/lograge/formatters/logstash.rb
lograge-0.11.1 lib/lograge/formatters/logstash.rb
lograge-0.11.0 lib/lograge/formatters/logstash.rb