diff options
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/clean_logger.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/clean_logger.rb b/activesupport/lib/active_support/clean_logger.rb index 330dbb2e46..89dfae8f2f 100644 --- a/activesupport/lib/active_support/clean_logger.rb +++ b/activesupport/lib/active_support/clean_logger.rb @@ -1,12 +1,22 @@ require 'logger' +require File.dirname(__FILE__) + '/class_attribute_accessors' class Logger #:nodoc: + cattr_accessor :silencer + self.silencer = true + # Silences the logger for the duration of the block. def silence(temporary_level = Logger::ERROR) - old_logger_level, self.level = level, temporary_level - yield self - ensure - self.level = old_logger_level + if silencer + begin + old_logger_level, self.level = level, temporary_level + yield self + ensure + self.level = old_logger_level + end + else + yield self + end end private |