diff options
author | Brian Durand <brian@embellishedvisions.com> | 2012-09-19 16:00:28 -0700 |
---|---|---|
committer | Brian Durand <brian@embellishedvisions.com> | 2012-09-19 16:00:28 -0700 |
commit | 19f0e37d7ae51c0a2b30f53127f68227ec55afec (patch) | |
tree | e70bc31e091a228054e0662b909319b02d65ab23 /actionmailer | |
parent | 01059d7f7fcf2780c425895e4bdd5395edb6436b (diff) | |
download | rails-19f0e37d7ae51c0a2b30f53127f68227ec55afec.tar.gz rails-19f0e37d7ae51c0a2b30f53127f68227ec55afec.tar.bz2 rails-19f0e37d7ae51c0a2b30f53127f68227ec55afec.zip |
Optimize log subscribers to check if the log level is sufficient before performing an operations.
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/log_subscriber.rb | 6 |
1 files changed, 4 insertions, 2 deletions
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 |