diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/logger.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/logger.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/logger.rb b/activesupport/lib/active_support/core_ext/logger.rb index 36c8f241b2..16fce81445 100644 --- a/activesupport/lib/active_support/core_ext/logger.rb +++ b/activesupport/lib/active_support/core_ext/logger.rb @@ -1,6 +1,5 @@ require 'active_support/core_ext/class/attribute_accessors' require 'active_support/deprecation' -require 'active_support/logger_silence' ActiveSupport::Deprecation.warn 'this file is deprecated and will be removed' @@ -34,7 +33,25 @@ require 'logger' # # Note: This logger is deprecated in favor of ActiveSupport::BufferedLogger class Logger - include LoggerSilence + ## + # :singleton-method: + # Set to false to disable the silencer + cattr_accessor :silencer + self.silencer = true + + # Silences the logger for the duration of the block. + def silence(temporary_level = Logger::ERROR) + 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 alias :old_datetime_format= :datetime_format= # Logging date-time format (string passed to +strftime+). Ignored if the formatter |