diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-10-30 16:53:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-30 16:53:06 -0400 |
commit | f4876545ffc8712fe5c62de2fff2822c7f9dad52 (patch) | |
tree | c23dcfae1293d2797ee2414c28e725c01b62c5f7 | |
parent | 3b2ea8b68352c1c4534ff30a086a16d00e8a12cf (diff) | |
parent | b0f2f5e348a409d52f126c446951fa4397a56302 (diff) | |
download | rails-f4876545ffc8712fe5c62de2fff2822c7f9dad52.tar.gz rails-f4876545ffc8712fe5c62de2fff2822c7f9dad52.tar.bz2 rails-f4876545ffc8712fe5c62de2fff2822c7f9dad52.zip |
Merge pull request #33972 from bogdanvlviv/follow-up-33897
Improve `enqueue_retry.active_job` message
-rw-r--r-- | activejob/lib/active_job/logging.rb | 12 | ||||
-rw-r--r-- | activejob/test/cases/logging_test.rb | 10 |
2 files changed, 13 insertions, 9 deletions
diff --git a/activejob/lib/active_job/logging.rb b/activejob/lib/active_job/logging.rb index 0abee4ed98..416be83c24 100644 --- a/activejob/lib/active_job/logging.rb +++ b/activejob/lib/active_job/logging.rb @@ -93,8 +93,12 @@ module ActiveJob ex = event.payload[:error] wait = event.payload[:wait] - error do - "Retrying #{job.class} in #{wait.inspect} seconds, due to a #{ex&.class.inspect}. The original exception was #{ex&.cause.inspect}." + info do + if ex + "Retrying #{job.class} in #{wait.to_i} seconds, due to a #{ex.class}." + else + "Retrying #{job.class} in #{wait.to_i} seconds." + end end end @@ -103,7 +107,7 @@ module ActiveJob ex = event.payload[:error] error do - "Stopped retrying #{job.class} due to a #{ex.class}, which reoccurred on #{job.executions} attempts. The original exception was #{ex.cause.inspect}." + "Stopped retrying #{job.class} due to a #{ex.class}, which reoccurred on #{job.executions} attempts." end end @@ -112,7 +116,7 @@ module ActiveJob ex = event.payload[:error] error do - "Discarded #{job.class} due to a #{ex.class}. The original exception was #{ex.cause.inspect}." + "Discarded #{job.class} due to a #{ex.class}." end end diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb index b5bf40c83b..48ef39aaca 100644 --- a/activejob/test/cases/logging_test.rb +++ b/activejob/test/cases/logging_test.rb @@ -169,19 +169,19 @@ class LoggingTest < ActiveSupport::TestCase def test_enqueue_retry_logging perform_enqueued_jobs do RetryJob.perform_later "DefaultsError", 2 - assert_match(/Retrying RetryJob in \d+ seconds, due to a DefaultsError\. The original exception was nil\./, @logger.messages) + assert_match(/Retrying RetryJob in 3 seconds, due to a DefaultsError\./, @logger.messages) end end def test_enqueue_retry_logging_on_retry_job perform_enqueued_jobs { RescueJob.perform_later "david" } - assert_match(/Retrying RescueJob in nil seconds, due to a nil\. The original exception was nil\./, @logger.messages) + assert_match(/Retrying RescueJob in 0 seconds\./, @logger.messages) end def test_retry_stopped_logging perform_enqueued_jobs do RetryJob.perform_later "CustomCatchError", 6 - assert_match(/Stopped retrying RetryJob due to a CustomCatchError, which reoccurred on \d+ attempts\. The original exception was #<CustomCatchError: CustomCatchError>\./, @logger.messages) + assert_match(/Stopped retrying RetryJob due to a CustomCatchError, which reoccurred on \d+ attempts\./, @logger.messages) end end @@ -190,7 +190,7 @@ class LoggingTest < ActiveSupport::TestCase begin RetryJob.perform_later "DefaultsError", 6 rescue DefaultsError - assert_match(/Stopped retrying RetryJob due to a DefaultsError, which reoccurred on \d+ attempts\. The original exception was #<DefaultsError: DefaultsError>\./, @logger.messages) + assert_match(/Stopped retrying RetryJob due to a DefaultsError, which reoccurred on \d+ attempts\./, @logger.messages) end end end @@ -198,7 +198,7 @@ class LoggingTest < ActiveSupport::TestCase def test_discard_logging perform_enqueued_jobs do RetryJob.perform_later "DiscardableError", 2 - assert_match(/Discarded RetryJob due to a DiscardableError\. The original exception was nil\./, @logger.messages) + assert_match(/Discarded RetryJob due to a DiscardableError\./, @logger.messages) end end end |