class CmLogger::LogrageFormatter
Public Instance Methods
call(data)
click to toggle source
# File lib/lograge_formatter.rb, line 3 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_formatter.rb, line 11 def fields_to_display(data) data.keys end
format(key, value)
click to toggle source
# File lib/lograge_formatter.rb, line 15 def format(key, value) "#{key}=#{parse_value(key, value)}" end
parse_value(key, value)
click to toggle source
# File lib/lograge_formatter.rb, line 19 def parse_value(key, value) if value.is_a? Float Kernel.format('%.2f', value) elsif value.is_a? String safe_value = value.gsub("\n", "\t") "'#{safe_value}'" else value end end