Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ougai/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def to_item(args)

if msg.nil?
{ msg: @default_message }
elsif ex.nil?
elsif ex.nil? && data.nil?
create_item_with_1arg(msg)
elsif data.nil?
create_item_with_2args(msg, ex)
Expand Down
18 changes: 18 additions & 0 deletions spec/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,24 @@ def to_hash
end
end

context 'with message, nil exception and data' do
it 'outputs valid' do
logger.send(method, log_msg, nil, something: { name: 'foo' })

expect(item).to be_log_message(log_msg, log_level)
expect(item).to include_data(something: { name: 'foo' })
end

it 'outputs valid by block' do
logger.send(method) do
[log_msg, nil, something: { name: 'foo' }]
end

expect(item).to be_log_message(log_msg, log_level)
expect(item).to include_data(something: { name: 'foo' })
end
end

context 'without arguments' do
it 'outputs only default message' do
logger.send(method)
Expand Down