lib/ougai/formatters/for_json.rb in ougai-1.6.5 vs lib/ougai/formatters/for_json.rb in ougai-1.6.6

- old
+ new

@@ -1,7 +1,5 @@ -require 'oj' - module Ougai # The features for JSON formatter # @attr [Boolean] jsonize Whether log should converts JSON # @attr [Boolean] with_newline Whether tailing NL should be appended module Formatters::ForJson @@ -10,10 +8,11 @@ protected def init_opts_for_json(opts) @jsonize = opts.fetch(:jsonize, true) @with_newline = opts.fetch(:with_newline, true) + @serializer = Ougai::Serializer.for_json end def to_level(severity) case severity when 'TRACE' @@ -31,17 +30,14 @@ else 70 end end - OJ_OPTIONS = { mode: :custom, time_format: :xmlschema, - use_as_json: true, use_to_hash: true, use_to_json: true } - # requires convert_time(data) method def dump(data) return data unless @jsonize convert_time(data) - str = Oj.dump(data, OJ_OPTIONS) + str = @serializer.serialize(data) str << "\n" if @with_newline str end end end