log_subscriber.rb 555 B

12345678910111213141516171819202122
  1. require 'active_support/core_ext/array/wrap'
  2. module ActionMailer
  3. class LogSubscriber < ActiveSupport::LogSubscriber
  4. def deliver(event)
  5. recipients = Array.wrap(event.payload[:to]).join(', ')
  6. info("\nSent mail to #{recipients} (%1.fms)" % event.duration)
  7. debug(event.payload[:mail])
  8. end
  9. def receive(event)
  10. info("\nReceived mail (%.1fms)" % event.duration)
  11. debug(event.payload[:mail])
  12. end
  13. def logger
  14. ActionMailer::Base.logger
  15. end
  16. end
  17. end
  18. ActionMailer::LogSubscriber.attach_to :action_mailer