Has anybody found the logging of the payload of emails annoying during testing and development?
In the code below for ActionMailer, it logs the full payload of emails. I like to turn this off while debugging even though I’m setting the logger to debug level.
What’s the cleanest way to override this? Maybe monkey patch the logger method? If so, any example?
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 logger
ActionMailer::Base.logger
end
end
end
ActionMailer::LogSubscriber.attach_to :action_mailer