class Fluent::Plugin::JSONFormatter
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
Fluent::Plugin::Newline::Mixin#configure
# File lib/fluent/plugin/formatter_json.rb, line 30 def configure(conf) super if @json_parser == 'oj' if Fluent::OjOptions.available? @dump_proc = Oj.method(:dump) else log.info "Oj isn't installed, fallback to Yajl as json parser" @dump_proc = Yajl.method(:dump) end else @dump_proc = Yajl.method(:dump) end # format json is used on various highload environment, so re-define method to skip if check unless @add_newline define_singleton_method(:format, method(:format_without_nl)) end end
format(tag, time, record)
click to toggle source
# File lib/fluent/plugin/formatter_json.rb, line 50 def format(tag, time, record) "#{@dump_proc.call(record)}#{@newline}" end
format_without_nl(tag, time, record)
click to toggle source
# File lib/fluent/plugin/formatter_json.rb, line 54 def format_without_nl(tag, time, record) @dump_proc.call(record) end