Class: Lograge::Formatters::LTSV
- Inherits:
-
Object
- Object
- Lograge::Formatters::LTSV
- Defined in:
- lib/lograge/formatters/ltsv.rb
Instance Method Summary collapse
Instance Method Details
#call(data) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/lograge/formatters/ltsv.rb', line 6 def call(data) fields = fields_to_display(data) event = fields.map { |key| format(key, data[key]) } event.join("\t") end |
#fields_to_display(data) ⇒ Object
13 14 15 |
# File 'lib/lograge/formatters/ltsv.rb', line 13 def fields_to_display(data) data.keys end |
#format(key, value) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lograge/formatters/ltsv.rb', line 17 def format(key, value) if key == :error # Exactly preserve the previous output # Parsing this can be ambigious if the error messages contains # a single quote value = "'#{escape value}'" elsif value.is_a? Float value = Kernel.format('%.2f', value) end "#{key}:#{value}" end |