Class: ActionMailer::LogSubscriber

Inherits:
ActiveSupport::EventReporter::LogSubscriber show all
Defined in:
actionmailer/lib/action_mailer/log_subscriber.rb

Overview

:nodoc:

Constant Summary

Constants inherited from ActiveSupport::EventReporter::LogSubscriber

ActiveSupport::EventReporter::LogSubscriber::LEVEL_CHECKS

Constants included from ActiveSupport::ColorizeLogging

ActiveSupport::ColorizeLogging::BLACK, ActiveSupport::ColorizeLogging::BLUE, ActiveSupport::ColorizeLogging::CYAN, ActiveSupport::ColorizeLogging::GREEN, ActiveSupport::ColorizeLogging::MAGENTA, ActiveSupport::ColorizeLogging::MODES, ActiveSupport::ColorizeLogging::RED, ActiveSupport::ColorizeLogging::WHITE, ActiveSupport::ColorizeLogging::YELLOW

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveSupport::EventReporter::LogSubscriber

#emit, event_log_level, #logger, subscription_filter

Methods included from ActiveSupport::ColorizeLogging

#color, #colorize_logging, #debug, #error, #fatal, #info, #mode_from, #unknown, #warn

Methods included from ActiveSupport::Concern

#append_features, #class_methods, extended, #included, #prepend_features, #prepended

Class Method Details

.default_loggerObject



36
37
38
# File 'actionmailer/lib/action_mailer/log_subscriber.rb', line 36

def self.default_logger
  ActionMailer::Base.logger
end

Instance Method Details

#delivered(event) ⇒ Object

An email was delivered.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'actionmailer/lib/action_mailer/log_subscriber.rb', line 10

def delivered(event)
  payload = event[:payload]
  info do
    if payload[:exception_class]
      "Failed delivery of mail #{payload[:message_id]} error_class=#{payload[:exception_class]} error_message=#{payload[:exception_message].inspect}"
    elsif payload[:perform_deliveries]
      "Delivered mail #{payload[:message_id]} (#{payload[:duration_ms].round(1)}ms)"
    else
      "Skipped delivery of mail #{payload[:message_id]} as `perform_deliveries` is false"
    end
  end

  debug { payload[:mail] }
end

#processed(event) ⇒ Object

An email was generated.



27
28
29
30
31
32
33
# File 'actionmailer/lib/action_mailer/log_subscriber.rb', line 27

def processed(event)
  debug do
    mailer = event[:payload][:mailer]
    action = event[:payload][:action]
    "#{mailer}##{action}: processed outbound mail in #{event[:payload][:duration_ms].round(1)}ms"
  end
end