FEATURE: Allow Unicorn logs to be JSON formatted.

This commit is contained in:
Guo Xiang Tan
2017-11-06 12:46:14 +08:00
parent a97273e1a5
commit c9df21e131
3 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,31 @@
require 'rails_helper'
require 'unicorn/unicorn_json_log_formatter'
RSpec.describe UnicornJSONLogFormatter do
context 'when message is an exception' do
it 'should include the backtrace' do
freeze_time do
begin
raise 'boom'
rescue => e
error = e
output = described_class.new.call(
'INFO',
Time.zone.now,
'',
e
)
end
output = JSON.parse(output)
expect(output["severity"]).to eq('INFO')
expect(output["datetime"]).to be_present
expect(output["progname"]).to eq('')
expect(output["pid"]).to be_present
expect(output["message"]).to match(/boom:.*/)
end
end
end
end