When sending emails via Actionmailer in Rails, it logs something like:
Sent mail to [email protected] (72ms)
  Rendered mailer/_header.html.erb (0.0ms)
  ...
I would like to filter the emails from logs ala parameter filtering
Sent mail to [FILTERED] (72ms)
  Rendered mailer/_header.html.erb (0.0ms)
  ...
Is there a clean way to do this? Alternatively, not logging the whole first line would be OK.
In Rails sourcecode ./actionmailer/lib/action_mailer/log_subscriber.rb:
module ActionMailer
  class LogSubscriber < ActiveSupport::LogSubscriber
    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
    def receive(event)
      return unless logger.info?
      info("\nReceived mail (#{event.duration.round(1)}ms)")
      debug(event.payload[:mail])
    end
    def logger
      ActionMailer::Base.logger
    end
  end
end
Rails is not providing a method to filter email, so you can:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With