Class: ActiveJob::Logging::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber show all
Defined in:
activejob/lib/active_job/logging.rb

Overview

:nodoc:

Constant Summary

Constants inherited from ActiveSupport::LogSubscriber

ActiveSupport::LogSubscriber::BLACK, ActiveSupport::LogSubscriber::BLUE, ActiveSupport::LogSubscriber::BOLD, ActiveSupport::LogSubscriber::CLEAR, ActiveSupport::LogSubscriber::CYAN, ActiveSupport::LogSubscriber::GREEN, ActiveSupport::LogSubscriber::MAGENTA, ActiveSupport::LogSubscriber::RED, ActiveSupport::LogSubscriber::WHITE, ActiveSupport::LogSubscriber::YELLOW

Instance Attribute Summary

Attributes inherited from ActiveSupport::Subscriber

#patterns

Instance Method Summary collapse

Methods inherited from ActiveSupport::LogSubscriber

#finish, flush_all!, log_subscribers, #start

Methods inherited from ActiveSupport::Subscriber

attach_to, #finish, #initialize, method_added, #start, subscribers

Constructor Details

This class inherits a constructor from ActiveSupport::Subscriber

Instance Method Details

#enqueue(event) ⇒ Object



57
58
59
60
61
62
# File 'activejob/lib/active_job/logging.rb', line 57

def enqueue(event)
  info do
    job = event.payload[:job]
    "Enqueued #{job.class.name} (Job ID: #{job.job_id}) to #{queue_name(event)}" + args_info(job)
  end
end

#enqueue_at(event) ⇒ Object



64
65
66
67
68
69
# File 'activejob/lib/active_job/logging.rb', line 64

def enqueue_at(event)
  info do
    job = event.payload[:job]
    "Enqueued #{job.class.name} (Job ID: #{job.job_id}) to #{queue_name(event)} at #{scheduled_at(event)}" + args_info(job)
  end
end

#perform(event) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'activejob/lib/active_job/logging.rb', line 78

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.message}):\n" + Array(ex.backtrace).join("\n")
    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



71
72
73
74
75
76
# File 'activejob/lib/active_job/logging.rb', line 71

def perform_start(event)
  info do
    job = event.payload[:job]
    "Performing #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)}" + args_info(job)
  end
end