Permalink
Browse files

delegating and deprecating logger#silence. fixes #4159

  • Loading branch information...
1 parent 0e8cbbe commit b590fe4892d312cbdde350e7c4f8fbbcaf8c61ee @tenderlove tenderlove committed Dec 24, 2011
@@ -1,4 +1,5 @@
require 'active_support/core_ext/class/attribute_accessors'
+require 'active_support/deprecation'
# Adds the 'around_level' method to Logger.
class Logger #:nodoc:
@@ -49,6 +50,7 @@ def silence(temporary_level = Logger::ERROR)
yield self
end
end
+ deprecate :silence
alias :old_datetime_format= :datetime_format=
# Logging date-time format (string passed to +strftime+). Ignored if the formatter
@@ -1,4 +1,5 @@
require 'active_support/core_ext/object/blank'
+require 'active_support/deprecation'
require 'logger'
module ActiveSupport
@@ -26,6 +27,11 @@ def tagged(*new_tags)
new_tags.size.times { tags.pop }
end
+ def silence(temporary_level = ERROR, &block)
+ @logger.silience(temporary_level, &block)
+ end
+ deprecate :silence
+
def add(severity, message = nil, progname = nil, &block)
@logger.add(severity, "#{tags_text}#{message}", progname, &block)
end
@@ -1,8 +1,11 @@
require 'abstract_unit'
require 'stringio'
require 'active_support/core_ext/logger'
+require 'active_support/testing/deprecation'
class CleanLoggerTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Deprecation
+
def setup
@out = StringIO.new
@logger = Logger.new(@out)
@@ -14,28 +17,34 @@ def test_format_message
end
def test_silence
- # Without yielding self.
- @logger.silence do
- @logger.debug 'debug'
- @logger.info 'info'
- @logger.warn 'warn'
- @logger.error 'error'
- @logger.fatal 'fatal'
+ assert_deprecated do
+ # Without yielding self.
+ @logger.silence do
+ @logger.debug 'debug'
+ @logger.info 'info'
+ @logger.warn 'warn'
+ @logger.error 'error'
+ @logger.fatal 'fatal'
+ end
end
- # Yielding self.
- @logger.silence do |logger|
- logger.debug 'debug'
- logger.info 'info'
- logger.warn 'warn'
- logger.error 'error'
- logger.fatal 'fatal'
+ assert_deprecated do
+ # Yielding self.
+ @logger.silence do |logger|
+ logger.debug 'debug'
+ logger.info 'info'
+ logger.warn 'warn'
+ logger.error 'error'
+ logger.fatal 'fatal'
+ end
end
# Silencer off.
Logger.silencer = false
- @logger.silence do |logger|
- logger.warn 'unsilenced'
+ assert_deprecated do
+ @logger.silence do |logger|
+ logger.warn 'unsilenced'
+ end
end
Logger.silencer = true

0 comments on commit b590fe4

Please sign in to comment.