From 19f0e37d7ae51c0a2b30f53127f68227ec55afec Mon Sep 17 00:00:00 2001 From: Brian Durand Date: Wed, 19 Sep 2012 16:00:28 -0700 Subject: Optimize log subscribers to check if the log level is sufficient before performing an operations. --- actionmailer/lib/action_mailer/log_subscriber.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/log_subscriber.rb b/actionmailer/lib/action_mailer/log_subscriber.rb index a6c163832e..fe1bca969c 100644 --- a/actionmailer/lib/action_mailer/log_subscriber.rb +++ b/actionmailer/lib/action_mailer/log_subscriber.rb @@ -1,13 +1,15 @@ module ActionMailer class LogSubscriber < ActiveSupport::LogSubscriber def deliver(event) + return unless logger.debug? recipients = Array(event.payload[:to]).join(', ') - info("\nSent mail to #{recipients} (%1.fms)" % event.duration) + info("\nSent mail to #{recipients} (#{event.duration.round(1)}ms)") debug(event.payload[:mail]) end def receive(event) - info("\nReceived mail (%.1fms)" % event.duration) + return unless logger.debug? + info("\nReceived mail (#{event.duration.round(1)}ms)") debug(event.payload[:mail]) end -- cgit v1.2.3