Class: ActiveJob::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- ActiveJob::LogSubscriber
- Defined in:
- lib/active_job/log_subscriber.rb
Overview
:nodoc:
Instance Method Summary collapse
- #discard(event) ⇒ Object
- #enqueue(event) ⇒ Object
- #enqueue_at(event) ⇒ Object
- #enqueue_retry(event) ⇒ Object
- #perform(event) ⇒ Object
- #perform_start(event) ⇒ Object
- #retry_stopped(event) ⇒ Object
Instance Method Details
#discard(event) ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/active_job/log_subscriber.rb', line 94 def discard(event) job = event.payload[:job] ex = event.payload[:error] error do "Discarded #{job.class} due to a #{ex.class}." end end |
#enqueue(event) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_job/log_subscriber.rb', line 8 def enqueue(event) job = event.payload[:job] ex = event.payload[:exception_object] || job.enqueue_error if ex error do "Failed enqueuing #{job.class.name} to #{queue_name(event)}: #{ex.class} (#{ex.})" end elsif event.payload[:aborted] info do "Failed enqueuing #{job.class.name} to #{queue_name(event)}, a before_enqueue callback halted the enqueuing execution." end else info do "Enqueued #{job.class.name} (Job ID: #{job.job_id}) to #{queue_name(event)}" + args_info(job) end end end |
#enqueue_at(event) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_job/log_subscriber.rb', line 27 def enqueue_at(event) job = event.payload[:job] ex = event.payload[:exception_object] || job.enqueue_error if ex error do "Failed enqueuing #{job.class.name} to #{queue_name(event)}: #{ex.class} (#{ex.})" end elsif event.payload[:aborted] info do "Failed enqueuing #{job.class.name} to #{queue_name(event)}, a before_enqueue callback halted the enqueuing execution." end else info do "Enqueued #{job.class.name} (Job ID: #{job.job_id}) to #{queue_name(event)} at #{scheduled_at(event).to_default_s}" + args_info(job) end end end |
#enqueue_retry(event) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/active_job/log_subscriber.rb', line 71 def enqueue_retry(event) job = event.payload[:job] ex = event.payload[:error] wait = event.payload[:wait] 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 |
#perform(event) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/active_job/log_subscriber.rb', line 53 def perform(event) job = event.payload[:job] ex = event.payload[:exception_object] if ex error do "Error performing #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)} in #{event.duration.round(2)}ms: #{ex.class} (#{ex.}):\n" + Array(ex.backtrace).join("\n") end elsif event.payload[:aborted] error do "Error performing #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)} in #{event.duration.round(2)}ms: a before_perform callback halted the job execution" end else info do "Performed #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)} in #{event.duration.round(2)}ms" end end end |
#perform_start(event) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/active_job/log_subscriber.rb', line 46 def perform_start(event) info do job = event.payload[:job] "Performing #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)} enqueued at #{job.enqueued_at}" + args_info(job) end end |
#retry_stopped(event) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/active_job/log_subscriber.rb', line 85 def retry_stopped(event) job = event.payload[:job] ex = event.payload[:error] error do "Stopped retrying #{job.class} due to a #{ex.class}, which reoccurred on #{job.executions} attempts." end end |