Sha256: 8473b72150b2768c889a49038174fce779b395477d09ab88bee64bc4c03c5dfe
Contents?: true
Size: 958 Bytes
Versions: 1
Compression:
Stored size: 958 Bytes
Contents
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.inject([]) do |message, key| next message unless data.has_key?(key) message << format(key, data[key]) message end event.join(" ") end def fields_to_display(data) LOGRAGE_FIELDS + (data.keys - LOGRAGE_FIELDS) end def format(key, value) # Exactly preserve the previous output # Parsing this can be ambigious if the error messages contains # a single quote value = "'#{value}'" if key == :error # Ensure that we always have exactly two decimals value = "%.2f" % value if value.is_a? Float "#{key}=#{value}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lograge-0.3.0 | lib/lograge/formatters/key_value.rb |