class Lograge::Formatters::KeyValue
Public Instance Methods
call(data)
click to toggle source
# File lib/lograge/formatters/key_value.rb, line 4 def call(data) fields_to_display(data) .map { |key| format(key, data[key]) } .join(' ') end
Protected Instance Methods
fields_to_display(data)
click to toggle source
# File lib/lograge/formatters/key_value.rb, line 12 def fields_to_display(data) data.keys end
format(key, value)
click to toggle source
# File lib/lograge/formatters/key_value.rb, line 16 def format(key, value) "#{key}=#{parse_value(key, value)}" end
parse_value(key, value)
click to toggle source
# File lib/lograge/formatters/key_value.rb, line 20 def parse_value(key, value) # Exactly preserve the previous output # Parsing this can be ambigious if the error messages contains # a single quote return "'#{value}'" if key == :error return Kernel.format('%.2f', value) if value.is_a? Float value end