diff options
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 1 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/log_subscriber.rb | 22 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 3 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railties/log_subscriber.rb | 22 | ||||
-rw-r--r-- | actionmailer/test/log_subscriber_test.rb | 8 |
5 files changed, 27 insertions, 29 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 44c7382f72..3b6e2c6387 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -4,6 +4,7 @@ require 'action_mailer/collector' require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/object/blank' require 'active_support/core_ext/proc' +require 'action_mailer/log_subscriber' module ActionMailer #:nodoc: # Action Mailer allows you to send email from your application using a mailer model and views. diff --git a/actionmailer/lib/action_mailer/log_subscriber.rb b/actionmailer/lib/action_mailer/log_subscriber.rb new file mode 100644 index 0000000000..7ba57b19e0 --- /dev/null +++ b/actionmailer/lib/action_mailer/log_subscriber.rb @@ -0,0 +1,22 @@ +require 'active_support/core_ext/array/wrap' + +module ActionMailer + class LogSubscriber < ActiveSupport::LogSubscriber + def deliver(event) + recipients = Array.wrap(event.payload[:to]).join(', ') + info("\nSent mail to #{recipients} (%1.fms)" % event.duration) + debug(event.payload[:mail]) + end + + def receive(event) + info("\nReceived mail (%.1fms)" % event.duration) + debug(event.payload[:mail]) + end + + def logger + ActionMailer::Base.logger + end + end +end + +ActionMailer::LogSubscriber.attach_to :action_mailer
\ No newline at end of file diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 43a4936013..d7b09b2dc6 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -5,9 +5,6 @@ module ActionMailer class Railtie < Rails::Railtie config.action_mailer = ActiveSupport::OrderedOptions.new - require "action_mailer/railties/log_subscriber" - log_subscriber :action_mailer, ActionMailer::Railties::LogSubscriber.new - initializer "action_mailer.logger" do ActiveSupport.on_load(:action_mailer) { self.logger ||= Rails.logger } end diff --git a/actionmailer/lib/action_mailer/railties/log_subscriber.rb b/actionmailer/lib/action_mailer/railties/log_subscriber.rb deleted file mode 100644 index af76d807d0..0000000000 --- a/actionmailer/lib/action_mailer/railties/log_subscriber.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'active_support/core_ext/array/wrap' - -module ActionMailer - module Railties - class LogSubscriber < Rails::LogSubscriber - def deliver(event) - recipients = Array.wrap(event.payload[:to]).join(', ') - info("\nSent mail to #{recipients} (%1.fms)" % event.duration) - debug(event.payload[:mail]) - end - - def receive(event) - info("\nReceived mail (%.1fms)" % event.duration) - debug(event.payload[:mail]) - end - - def logger - ActionMailer::Base.logger - end - end - end -end diff --git a/actionmailer/test/log_subscriber_test.rb b/actionmailer/test/log_subscriber_test.rb index c08c34b4a2..ba9b4d6500 100644 --- a/actionmailer/test/log_subscriber_test.rb +++ b/actionmailer/test/log_subscriber_test.rb @@ -1,13 +1,13 @@ require "abstract_unit" -require "rails/log_subscriber/test_helper" -require "action_mailer/railties/log_subscriber" +require "active_support/log_subscriber/test_helper" +require "action_mailer/log_subscriber" class AMLogSubscriberTest < ActionMailer::TestCase - include Rails::LogSubscriber::TestHelper + include ActiveSupport::LogSubscriber::TestHelper def setup super - Rails::LogSubscriber.add(:action_mailer, ActionMailer::Railties::LogSubscriber.new) + ActionMailer::LogSubscriber.attach_to :action_mailer end class TestMailer < ActionMailer::Base |