mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
log context as a JSON string
This commit is contained in:
parent
637a460005
commit
a1f98fbbf2
2 changed files with 2 additions and 2 deletions
|
@ -5,7 +5,7 @@ module Sidekiq
|
||||||
|
|
||||||
class Logger
|
class Logger
|
||||||
def call(ex, ctxHash)
|
def call(ex, ctxHash)
|
||||||
Sidekiq.logger.warn(ctxHash) if !ctxHash.empty?
|
Sidekiq.logger.warn(Sidekiq.dump_json(ctxHash)) if !ctxHash.empty?
|
||||||
Sidekiq.logger.warn "#{ex.class.name}: #{ex.message}"
|
Sidekiq.logger.warn "#{ex.class.name}: #{ex.message}"
|
||||||
Sidekiq.logger.warn ex.backtrace.join("\n") unless ex.backtrace.nil?
|
Sidekiq.logger.warn ex.backtrace.join("\n") unless ex.backtrace.nil?
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ class TestExceptionHandler < Sidekiq::Test
|
||||||
Component.new.invoke_exception(:a => 1)
|
Component.new.invoke_exception(:a => 1)
|
||||||
@str_logger.rewind
|
@str_logger.rewind
|
||||||
log = @str_logger.readlines
|
log = @str_logger.readlines
|
||||||
assert_match(/a=>1/, log[0], "didn't include the context")
|
assert_match(/"a":1/, log[0], "didn't include the context")
|
||||||
assert_match(/Something didn't work!/, log[1], "didn't include the exception message")
|
assert_match(/Something didn't work!/, log[1], "didn't include the exception message")
|
||||||
assert_match(/test\/test_exception_handler.rb/, log[2], "didn't include the backtrace")
|
assert_match(/test\/test_exception_handler.rb/, log[2], "didn't include the backtrace")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue