Fix incorrect severity field.

This commit is contained in:
Guo Xiang Tan 2017-11-07 11:24:40 +08:00
parent bf82b34f10
commit d9602fe729
2 changed files with 5 additions and 3 deletions

View File

@ -3,7 +3,8 @@ require 'json'
class UnicornJSONLogFormatter < Logger::Formatter class UnicornJSONLogFormatter < Logger::Formatter
def call(severity, datetime, progname, message) def call(severity, datetime, progname, message)
default = { default = {
severity: severity, severity: "Logger::Severity::#{severity}".constantize,
severity_name: severity,
datetime: DateTime.parse(datetime.to_s).to_s, datetime: DateTime.parse(datetime.to_s).to_s,
progname: progname || '', progname: progname || '',
pid: $$, pid: $$,

View File

@ -11,7 +11,7 @@ RSpec.describe UnicornJSONLogFormatter do
error = e error = e
output = described_class.new.call( output = described_class.new.call(
'INFO', 'ERROR',
Time.zone.now, Time.zone.now,
'', '',
e e
@ -20,7 +20,8 @@ RSpec.describe UnicornJSONLogFormatter do
output = JSON.parse(output) output = JSON.parse(output)
expect(output["severity"]).to eq('INFO') expect(output["severity"]).to eq(3)
expect(output["severity_name"]).to eq("ERROR")
expect(output["datetime"]).to be_present expect(output["datetime"]).to be_present
expect(output["progname"]).to eq('') expect(output["progname"]).to eq('')
expect(output["pid"]).to be_present expect(output["pid"]).to be_present