lib/ougai/formatters/bunyan.rb in ougai-1.4.2 vs lib/ougai/formatters/bunyan.rb in ougai-1.4.3
- old
+ new
@@ -2,15 +2,16 @@
require 'json'
module Ougai
module Formatters
class Bunyan < Base
- attr_accessor :jsonize
+ attr_accessor :jsonize, :with_newline
def initialize
super
@jsonize = true
+ @with_newline = true
end
def call(severity, time, progname, data)
dump({
name: progname || @app_name,
@@ -42,10 +43,12 @@
private
def dump(data)
return data unless @jsonize
data[:time] = data[:time].iso8601(3)
- JSON.generate(data) + "\n"
+ str = JSON.generate(data)
+ str << "\n" if @with_newline
+ str
end
end
end
end