From e66498a861615423bcee08b09e85929ae6e98543 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Tue, 17 Oct 2017 12:16:03 -0400 Subject: [PATCH] add logging for delayedJob --- config/initializers/delayed_job.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/config/initializers/delayed_job.rb b/config/initializers/delayed_job.rb index d3132394..c4725b19 100644 --- a/config/initializers/delayed_job.rb +++ b/config/initializers/delayed_job.rb @@ -1,9 +1,14 @@ -Delayed::Worker.class_eval do - - def handle_failed_job_with_notification(job, error) - handle_failed_job_without_notification(job, error) - ExceptionNotifier.notify_exception(error) - end - alias_method_chain :handle_failed_job, :notification +# frozen_string_literal: true +module ExceptionNotifierInDelayedJob + def handle_failed_job(job, error) + super + ExceptionNotfier.notify_exception(error) + end end + +Delayed::Worker.class_eval do + prepend ExceptionNotifierInDelayedJob +end + +Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))