Permalink
Browse files

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
  • Loading branch information...
1 parent ea85fb6 commit 7d423690715de123a44ddee1b00c31404ab6021d @dhh dhh committed May 2, 2005
Showing with 4 additions and 6 deletions.
  1. +4 −6 activesupport/lib/active_support/clean_logger.rb
@@ -2,13 +2,11 @@
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

0 comments on commit 7d42369

Please sign in to comment.