Class: Fluent::TextFormatter::JSONishFormatter
- Inherits:
-
JSONFormatter
- Object
- JSONFormatter
- Fluent::TextFormatter::JSONishFormatter
- Defined in:
- lib/fluent/plugin/formatter_jsonish.rb
Direct Known Subclasses
Instance Method Summary collapse
- #format(tag, time, record) ⇒ Object
- #format_without_nl(tag, time, record) ⇒ Object
- #update_entry(tag, time, record) ⇒ Object
Instance Method Details
#format(tag, time, record) ⇒ Object
35 36 37 |
# File 'lib/fluent/plugin/formatter_jsonish.rb', line 35 def format(tag, time, record) super(*update_entry(tag, time, record)) end |
#format_without_nl(tag, time, record) ⇒ Object
39 40 41 |
# File 'lib/fluent/plugin/formatter_jsonish.rb', line 39 def format_without_nl(tag, time, record) super(*update_entry(tag, time, record)) end |
#update_entry(tag, time, record) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fluent/plugin/formatter_jsonish.rb', line 13 def update_entry(tag, time, record) merge_hash = {} if @add_time.key?('key') if not @add_time.key?('format') or @add_time['format'] == 'iso8601(3)' merge_hash[@add_time['key']] = Time.at(time.to_r).iso8601(3) else merge_hash[@add_time['key']] = eval("Time.at(time.to_r).#{@add_time['format']}") end end if @add_tag.key?('key') if not @add_tag.key?('format') or @add_tag['format'] == 'to_s' merge_hash[@add_tag['key']] = tag.to_s else merge_hash[@add_tag['key']] = eval("tag.#{@add_tag['format']}") end end return tag, time, record.merge(merge_hash) end |