Module: DelayedJobLogging

Defined in:
lib/delayed_job_logging.rb,
lib/delayed_job_logging/version.rb

Overview

Delayed Job Workers including this will log when a job was enqueued, started, succeeded or failed to the Rails logs. It’s important to call ‘super` if they implement these callback methods: `enqueue`, `before`, `success` or `error`

Defined Under Namespace

Classes: LogMessage

Constant Summary collapse

VERSION =
"0.1.1"

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.loggerObject



11
12
13
# File 'lib/delayed_job_logging.rb', line 11

def logger
  @logger || Delayed::Job.logger || fail("No logger available!")
end

Instance Method Details

#before(job) ⇒ Object



20
21
22
# File 'lib/delayed_job_logging.rb', line 20

def before(job)
  LogMessage.new(job).log("started")
end

#enqueue(job) ⇒ Object



16
17
18
# File 'lib/delayed_job_logging.rb', line 16

def enqueue(job)
  LogMessage.new(job).log("enqueued")
end

#error(job, exception) ⇒ Object



28
29
30
# File 'lib/delayed_job_logging.rb', line 28

def error(job, exception)
  LogMessage.new(job).log("failed", exception: exception)
end

#success(job) ⇒ Object



24
25
26
# File 'lib/delayed_job_logging.rb', line 24

def success(job)
  LogMessage.new(job).log("succeeded")
end