From bf2009f995dd8cf5cbe43908de18580d0e94e2e1 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 26 Oct 2012 16:18:39 -0700 Subject: Job consumer logs to Rails.logger by default --- activesupport/lib/active_support/queueing.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/queueing.rb b/activesupport/lib/active_support/queueing.rb index 6de038ee0e..064f009f13 100644 --- a/activesupport/lib/active_support/queueing.rb +++ b/activesupport/lib/active_support/queueing.rb @@ -64,9 +64,12 @@ module ActiveSupport # queue and joins the thread, which will ensure that all jobs # are executed before the process finally dies. class ThreadedQueueConsumer + attr_accessor :logger + def initialize(queue, options = {}) @queue = queue - @logger = options[:logger] || Logger.new($stderr) + @logger = options[:logger] + @fallback_logger = Logger.new($stderr) end def start @@ -96,7 +99,7 @@ module ActiveSupport end def handle_exception(job, exception) - @logger.error "Job Error: #{job.inspect}\n#{exception.message}\n#{exception.backtrace.join("\n")}" + (logger || @fallback_logger).error "Job Error: #{job.inspect}\n#{exception.message}\n#{exception.backtrace.join("\n")}" end end end -- cgit v1.2.3