Class: ActiveJob::LogSubscriber
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: |
ActiveSupport::EventReporter::LogSubscriber
|
| Defined in: | activejob/lib/active_job/log_subscriber.rb |
Constant Summary
::ActiveSupport::ColorizeLogging - Included
BLACK, BLUE, CYAN, GREEN, MAGENTA, MODES, RED, WHITE, YELLOW
::ActiveSupport::EventReporter::LogSubscriber - Inherited
Class Attribute Summary
::ActiveSupport::EventReporter::LogSubscriber - Inherited
Class Method Summary
::ActiveSupport::EventReporter::LogSubscriber - Inherited
Instance Attribute Summary
::ActiveSupport::EventReporter::LogSubscriber - Inherited
Instance Method Summary
- #bulk_enqueued(event)
- #completed(event)
- #discarded(event)
- #enqueued(event)
- #enqueued_at(event)
- #interrupt(event)
- #resume(event)
- #retry_scheduled(event)
- #retry_stopped(event)
- #started(event)
- #step(event)
- #step_skipped(event)
- #step_started(event)
- #args_info(event) private
- #enqueue_source_location private
- #enqueued_jobs_message(event) private
- #error(progname = nil, &block) private
- #format(arg) private
- #info(progname = nil, &block) private
- #log_enqueue_source private
- #queue_name(event) private
::ActiveSupport::EventReporter::LogSubscriber - Inherited
::ActiveSupport::ColorizeLogging - Included
| #color | Set color by using a symbol or one of the defined constants. |
| #colorize_logging, #debug, #error, #fatal, #info, #mode_from, #unknown, #warn | |
Class Attribute Details
.backtrace_cleaner (rw)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 7
class_attribute :backtrace_cleaner, default: ActiveSupport::BacktraceCleaner.new
.backtrace_cleaner? ⇒ Boolean (rw)
[ GitHub ]
# File 'activejob/lib/active_job/log_subscriber.rb', line 7
class_attribute :backtrace_cleaner, default: ActiveSupport::BacktraceCleaner.new
Class Method Details
.default_logger
[ GitHub ]Instance Attribute Details
#backtrace_cleaner (rw)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 7
class_attribute :backtrace_cleaner, default: ActiveSupport::BacktraceCleaner.new
#backtrace_cleaner? ⇒ Boolean (rw)
[ GitHub ]
# File 'activejob/lib/active_job/log_subscriber.rb', line 7
class_attribute :backtrace_cleaner, default: ActiveSupport::BacktraceCleaner.new
Instance Method Details
#args_info(event) (private)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 201
def args_info(event) if (arguments = event[:payload][:arguments]) " with arguments: " + arguments.map { |arg| format(arg).inspect }.join(", ") else "" end end
#bulk_enqueued(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 49
def bulk_enqueued(event) payload = event[:payload] info do if payload[:enqueued_count] == payload[:job_count] (event) elsif payload[:enqueued_count] > 0 if payload[:failed_enqueue_count] == 0 (event) else "#{(event)}. "\ "Failed enqueuing #{payload[:failed_enqueue_count]} #{'job'.pluralize(payload[:failed_enqueue_count])}" end else "Failed enqueuing #{payload[:failed_enqueue_count]} #{'job'.pluralize(payload[:failed_enqueue_count])} "\ "to #{payload[:adapter]}" end end end
#completed(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 81
def completed(event) payload = event[:payload] if payload[:exception_class] cleaned_backtrace = backtrace_cleaner.clean(payload[:exception_backtrace]) error do "Error performing #{payload[:job_class]} (Job ID: #{payload[:job_id]}) from #{queue_name(event)} in #{payload[:duration]}ms: #{payload[:exception_class]} (#{payload[:]}):\n" + Array(cleaned_backtrace).join("\n") end elsif payload[:aborted] error do "Error performing #{payload[:job_class]} (Job ID: #{payload[:job_id]}) from #{queue_name(event)} in #{payload[:duration]}ms: a before_perform callback halted the job execution" end else info do "Performed #{payload[:job_class]} (Job ID: #{payload[:job_id]}) from #{queue_name(event)} in #{payload[:duration]}ms" end end end
#discarded(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 123
def discarded(event) payload = event[:payload] error do "Discarded #{payload[:job_class]} (Job ID: #{payload[:job_id]}) due to a #{payload[:exception_class]} (#{payload[:]})." end end
#enqueue_source_location (private)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 247
def enqueue_source_location backtrace_cleaner.first_clean_frame end
#enqueued(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 11
def enqueued(event) payload = event[:payload] if payload[:exception_class] error do "Failed enqueuing #{payload[:job_class]} to #{queue_name(event)}: #{payload[:exception_class]} (#{payload[:]})" end elsif payload[:aborted] info do "Failed enqueuing #{payload[:job_class]} to #{queue_name(event)}, a before_enqueue callback halted the enqueuing execution." end else info do "Enqueued #{payload[:job_class]} (Job ID: #{payload[:job_id]}) to #{queue_name(event)}" + args_info(event) end end end
#enqueued_at(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 30
def enqueued_at(event) payload = event[:payload] if payload[:exception_class] error do "Failed enqueuing #{payload[:job_class]} to #{queue_name(event)}: #{payload[:exception_class]} (#{payload[:]})" end elsif payload[:aborted] info do "Failed enqueuing #{payload[:job_class]} to #{queue_name(event)}, a before_enqueue callback halted the enqueuing execution." end else info do "Enqueued #{payload[:job_class]} (Job ID: #{payload[:job_id]}) to #{queue_name(event)} at #{event[:payload][:scheduled_at]}" + args_info(event) end end end
#enqueued_jobs_message(event) (private)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 251
def (event) payload = event[:payload] enqueued_count = payload[:enqueued_count] job_classes_counts = payload[:enqueued_classes].sort_by { |_k, v| -v } "Enqueued #{enqueued_count} #{'job'.pluralize(enqueued_count)} to #{payload[:adapter]}"\ " (#{job_classes_counts.map { |klass, count| "#{count} #{klass}" }.join(', ')})" end
#error(progname = nil, &block) (private)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 231
def error(progname = nil, &block) return unless super if ActiveJob.verbose_enqueue_logs log_enqueue_source end end
#format(arg) (private)
[ GitHub ]#info(progname = nil, &block) (private)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 223
def info(progname = nil, &block) return unless super if ActiveJob.verbose_enqueue_logs log_enqueue_source end end
#interrupt(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 132
def interrupt(event) payload = event[:payload] info do "Interrupted #{payload[:job_class]} (Job ID: #{payload[:job_id]}) #{payload[:description]} (#{payload[:reason]})" end end
#log_enqueue_source (private)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 239
def log_enqueue_source source = enqueue_source_location if source logger.info("↳ #{source}") end end
#queue_name(event) (private)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 196
def queue_name(event) adapter, queue = event[:payload].values_at(:adapter, :queue) "#{adapter}(#{queue})" end
#resume(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 141
def resume(event) payload = event[:payload] info do "Resuming #{payload[:job_class]} (Job ID: #{payload[:job_id]}) #{payload[:description]}" end end
#retry_scheduled(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 101
def retry_scheduled(event) payload = event[:payload] info do if payload[:exception_class] "Retrying #{payload[:job_class]} (Job ID: #{payload[:job_id]}) after #{payload[:executions]} attempts in #{payload[:wait_seconds]} seconds, due to a #{payload[:exception_class]} (#{payload[:]})." else "Retrying #{payload[:job_class]} (Job ID: #{payload[:job_id]}) after #{payload[:executions]} attempts in #{payload[:wait_seconds]} seconds." end end end
#retry_stopped(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 114
def retry_stopped(event) payload = event[:payload] error do "Stopped retrying #{payload[:job_class]} (Job ID: #{payload[:job_id]}) due to a #{payload[:exception_class]} (#{payload[:]}), which reoccurred on #{payload[:executions]} attempts." end end
#started(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 70
def started(event) payload = event[:payload] info do enqueue_info = payload[:enqueued_at].present? ? " enqueued at #{payload[:enqueued_at]}" : "" "Performing #{payload[:job_class]} (Job ID: #{payload[:job_id]}) from #{queue_name(event)}" + enqueue_info + args_info(event) end end
#step(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 172
def step(event) payload = event[:payload] if payload[:interrupted] info do "Step '#{payload[:step]}' interrupted at cursor '#{payload[:cursor]}' for #{payload[:job_class]} (Job ID: #{payload[:job_id]}) in #{payload[:duration]}ms" end elsif payload[:exception_class] error do "Error during step '#{payload[:step]}' at cursor '#{payload[:cursor]}' for #{payload[:job_class]} (Job ID: #{payload[:job_id]}) in #{payload[:duration]}ms: #{payload[:exception_class]} (#{payload[:]})" end else info do "Step '#{payload[:step]}' completed for #{payload[:job_class]} (Job ID: #{payload[:job_id]}) in #{payload[:duration]}ms" end end end
#step_skipped(event)
[ GitHub ]#step_started(event)
[ GitHub ]# File 'activejob/lib/active_job/log_subscriber.rb', line 159
def step_started(event) payload = event[:payload] info do if payload[:resumed] "Step '#{payload[:step]}' resumed from cursor '#{payload[:cursor]}' for #{payload[:job_class]} (Job ID: #{payload[:job_id]})" else "Step '#{payload[:step]}' started for #{payload[:job_class]} (Job ID: #{payload[:job_id]})" end end end