Class: ActionMailer::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/action_mailer/log_subscriber.rb

Instance Method Summary collapse

Instance Method Details

#deliver(event) ⇒ Object



3
4
5
6
7
8
# File 'lib/action_mailer/log_subscriber.rb', line 3

def deliver(event)
  return unless logger.info?
  recipients = Array(event.payload[:to]).join(', ')
  info("\nSent mail to #{recipients} (#{event.duration.round(1)}ms)")
  debug(event.payload[:mail])
end

#loggerObject



16
17
18
# File 'lib/action_mailer/log_subscriber.rb', line 16

def logger
  ActionMailer::Base.logger
end

#receive(event) ⇒ Object



10
11
12
13
14
# File 'lib/action_mailer/log_subscriber.rb', line 10

def receive(event)
  return unless logger.info?
  info("\nReceived mail (#{event.duration.round(1)}ms)")
  debug(event.payload[:mail])
end