Skip to content

Commit

Permalink
Remove needless data filter in key value formatter
Browse files Browse the repository at this point in the history
We don't need to filter data because we skip them anyway
if the key does not exist.
  • Loading branch information
Peter Suschlik committed Oct 15, 2014
1 parent 63f61f7 commit caf7ffe
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/lograge/formatters/key_value.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
module Lograge
module Formatters
class KeyValue
LOGRAGE_FIELDS = [
:method, :path, :format, :controller, :action, :status, :error,
:duration, :view, :db, :location
]

def call(data)
fields = fields_to_display(data)

event = fields.reduce([]) do |message, key|
next message unless data.key?(key)

message << format(key, data[key])
message
end
event.join(' ')
end

def fields_to_display(data)
LOGRAGE_FIELDS + (data.keys - LOGRAGE_FIELDS)
data.keys
end

def format(key, value)
Expand Down

0 comments on commit caf7ffe

Please sign in to comment.