diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/log_subscriber.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/log_subscriber.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/actionmailer/lib/action_mailer/log_subscriber.rb b/actionmailer/lib/action_mailer/log_subscriber.rb index 3fe64759ac..eb6fb11d81 100644 --- a/actionmailer/lib/action_mailer/log_subscriber.rb +++ b/actionmailer/lib/action_mailer/log_subscriber.rb @@ -1,5 +1,10 @@ +require 'active_support/log_subscriber' + module ActionMailer + # Implements the ActiveSupport::LogSubscriber for logging notifications when + # email is delivered and received. class LogSubscriber < ActiveSupport::LogSubscriber + # An email was delivered. def deliver(event) return unless logger.info? recipients = Array(event.payload[:to]).join(', ') @@ -7,12 +12,21 @@ module ActionMailer debug(event.payload[:mail]) end + # An email was received. def receive(event) return unless logger.info? info("\nReceived mail (#{event.duration.round(1)}ms)") debug(event.payload[:mail]) end + # An email was generated. + def process(event) + mailer = event.payload[:mailer] + action = event.payload[:action] + debug("\n#{mailer}##{action}: processed outbound mail in #{event.duration.round(1)}ms") + end + + # Use the logger configured for ActionMailer::Base def logger ActionMailer::Base.logger end |