Lograge formatter (#40)

* add lograge formatter

* simplify mapping
This commit is contained in:
Raffael Schmid 2017-09-01 09:59:00 +02:00 committed by Adrian Serafin
parent 30f7c515c1
commit eea802b546
2 changed files with 17 additions and 0 deletions

View file

@ -2,6 +2,7 @@ require 'grape_logging/multi_io'
require 'grape_logging/version'
require 'grape_logging/formatters/default'
require 'grape_logging/formatters/json'
require 'grape_logging/formatters/lograge'
require 'grape_logging/formatters/logstash'
require 'grape_logging/loggers/base'
require 'grape_logging/loggers/response'

View file

@ -0,0 +1,16 @@
module GrapeLogging
module Formatters
class Lograge
def call(severity, datetime, _, data)
time = data.delete :time
attributes = {
severity: severity,
duration: time[:total],
db: time[:db],
view: time[:view]
}.merge(data)
::Lograge.formatter.call(attributes) + "\n"
end
end
end
end