Permalink
Browse files

Merge pull request #7643 from steveklabnik/deprecate_silence

Deprecate ActiveSupport::Benchmarkable#silence.
  • Loading branch information...
2 parents 3ec6783 + ed2fea9 commit 1b7894c95b1bdd2a3dca204629b66060f8a16bca @rafaelfranca rafaelfranca committed Sep 15, 2012
@@ -1619,26 +1619,32 @@ def test_becomes_includes_errors
def test_silence_sets_log_level_to_error_in_block
original_logger = ActiveRecord::Base.logger
- log = StringIO.new
- ActiveRecord::Base.logger = ActiveSupport::Logger.new(log)
- ActiveRecord::Base.logger.level = Logger::DEBUG
- ActiveRecord::Base.silence do
- ActiveRecord::Base.logger.warn "warn"
- ActiveRecord::Base.logger.error "error"
+
+ assert_deprecated do
+ log = StringIO.new
+ ActiveRecord::Base.logger = ActiveSupport::Logger.new(log)
+ ActiveRecord::Base.logger.level = Logger::DEBUG
+ ActiveRecord::Base.silence do
+ ActiveRecord::Base.logger.warn "warn"
+ ActiveRecord::Base.logger.error "error"
+ end
+ assert_equal "error\n", log.string
end
- assert_equal "error\n", log.string
ensure
ActiveRecord::Base.logger = original_logger
end
def test_silence_sets_log_level_back_to_level_before_yield
original_logger = ActiveRecord::Base.logger
- log = StringIO.new
- ActiveRecord::Base.logger = ActiveSupport::Logger.new(log)
- ActiveRecord::Base.logger.level = Logger::WARN
- ActiveRecord::Base.silence do
+
+ assert_deprecated do
+ log = StringIO.new
+ ActiveRecord::Base.logger = ActiveSupport::Logger.new(log)
+ ActiveRecord::Base.logger.level = Logger::WARN
+ ActiveRecord::Base.silence do
+ end
+ assert_equal Logger::WARN, ActiveRecord::Base.logger.level
end
- assert_equal Logger::WARN, ActiveRecord::Base.logger.level
ensure
ActiveRecord::Base.logger = original_logger
end
@@ -1,5 +1,9 @@
## Rails 4.0.0 (unreleased) ##
+* ActiveSupport::Benchmarkable#silence has been deprecated due to its lack of
+ thread safety. It will be removed without replacement in Rails 4.1. *Steve
+ Klabnik*
+
* An optional block can be passed to `Hash#deep_merge`. The block will be invoked for each duplicated key
and used to resolve the conflict. *Pranas Kiziela*
@@ -46,6 +46,7 @@ def benchmark(message = "Benchmarking", options = {})
# Silence the logger during the execution of the block.
#
def silence
+ ActiveSupport::Deprecation.warn "ActiveSupport::Benchmarkable#silence is deprecated. It will be removed from Rails 4.1."
old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger
yield
ensure

0 comments on commit 1b7894c

Please sign in to comment.