class Fluent::Plugin::JSONFormatter
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
Fluent::Plugin::Base#configure
# File lib/fluent/plugin/formatter_json.rb, line 28 def configure(conf) super begin raise LoadError unless @json_parser == 'oj' require 'oj' Oj.default_options = Fluent::DEFAULT_OJ_OPTIONS @dump_proc = Oj.method(:dump) rescue LoadError @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 46 def format(tag, time, record) "#{@dump_proc.call(record)}\n" end
format_without_nl(tag, time, record)
click to toggle source
# File lib/fluent/plugin/formatter_json.rb, line 50 def format_without_nl(tag, time, record) @dump_proc.call(record) end