aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-06-24 13:23:43 +0200
committerJosé Valim <jose.valim@gmail.com>2010-06-24 13:23:43 +0200
commit6788db824ab732b13493a9d702dd8fb89fa153c8 (patch)
treead9314fdd10b55ebb035959a71be0de921cb0d02 /actionmailer/lib/action_mailer
parent5441e082f9478ddb3c676c681b09786f1391483c (diff)
downloadrails-6788db824ab732b13493a9d702dd8fb89fa153c8.tar.gz
rails-6788db824ab732b13493a9d702dd8fb89fa153c8.tar.bz2
rails-6788db824ab732b13493a9d702dd8fb89fa153c8.zip
Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing frameworks like ActiveRecord and ActiveResource to log outsude Rails::Application [#4816 state:resolved]
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r--actionmailer/lib/action_mailer/base.rb1
-rw-r--r--actionmailer/lib/action_mailer/log_subscriber.rb22
-rw-r--r--actionmailer/lib/action_mailer/railtie.rb3
-rw-r--r--actionmailer/lib/action_mailer/railties/log_subscriber.rb22
4 files changed, 23 insertions, 25 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