diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/log_subscriber.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/log_subscriber.rb | 22 |
1 files changed, 22 insertions, 0 deletions
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 |