mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FEATURE: Allow Unicorn logs to be JSON formatted.
This commit is contained in:
31
spec/components/unicorn/unicorn_json_log_formatter_spec.rb
Normal file
31
spec/components/unicorn/unicorn_json_log_formatter_spec.rb
Normal 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
|
Reference in New Issue
Block a user