Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
delayedjob plugin to log backtraces
module Delayed
module Plugins
class LogErrors < Plugin
callbacks do |lifecycle|
lifecycle.around(:invoke_job) do |job, &block|
begin
block.call(job)
rescue Exception => error
Delayed::Worker.logger.error(error.message)
Delayed::Worker.logger.error(error.backtrace.join("\n"))
raise
end
end
end
end
end
end
if Rails.env.development?
Delayed::Worker.plugins << Delayed::Plugins::LogErrors
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.