aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-02 17:20:18 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-02 17:20:18 +0000
commit7d423690715de123a44ddee1b00c31404ab6021d (patch)
treea15de18799c6ccc0d213cf0eef12b73e3af2b058 /activesupport/lib
parentea85fb6322a2e908f0b50fda7625b85aa66fe846 (diff)
downloadrails-7d423690715de123a44ddee1b00c31404ab6021d.tar.gz
rails-7d423690715de123a44ddee1b00c31404ab6021d.tar.bz2
rails-7d423690715de123a44ddee1b00c31404ab6021d.zip
Improved the silence method on the logger to ensure restoring the old level #1240 [bitsweat
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1277 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/clean_logger.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/clean_logger.rb b/activesupport/lib/active_support/clean_logger.rb
index df9a6867ec..3632a27c40 100644
--- a/activesupport/lib/active_support/clean_logger.rb
+++ b/activesupport/lib/active_support/clean_logger.rb
@@ -2,13 +2,11 @@ require 'logger'
class Logger #:nodoc:
# Silences the logger for the duration of the block.
- def silence
- result = nil
- old_logger_level = level
- self.level = Logger::ERROR
- result = yield
+ def silence(temporary_level = Logger::ERROR)
+ old_logger_level, self.level = level, temporary_level
+ yield
+ ensure
self.level = old_logger_level
- return result
end
private