aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/clean_logger.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-02 11:41:24 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-02 11:41:24 +0000
commit3135ec40a3304eb79284c4447b0ffc79867f6224 (patch)
treee48cb1b5ae5fdaca6b23b681ad9c7770aaddd248 /activesupport/lib/active_support/clean_logger.rb
parent1edb807aff0d0f21cdc36447f7d671e10b542946 (diff)
downloadrails-3135ec40a3304eb79284c4447b0ffc79867f6224.tar.gz
rails-3135ec40a3304eb79284c4447b0ffc79867f6224.tar.bz2
rails-3135ec40a3304eb79284c4447b0ffc79867f6224.zip
Added silencing to the default Logger class
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1271 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/clean_logger.rb')
-rw-r--r--activesupport/lib/active_support/clean_logger.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/clean_logger.rb b/activesupport/lib/active_support/clean_logger.rb
index 1a36562892..df9a6867ec 100644
--- a/activesupport/lib/active_support/clean_logger.rb
+++ b/activesupport/lib/active_support/clean_logger.rb
@@ -1,6 +1,16 @@
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
+ self.level = old_logger_level
+ return result
+ end
+
private
remove_const "Format"
Format = "%s\n"