diff options
-rw-r--r-- | actionpack/CHANGELOG | 1 | ||||
-rw-r--r-- | activerecord/CHANGELOG | 4 | ||||
-rw-r--r-- | activesupport/CHANGELOG | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/clean_logger.rb | 18 | ||||
-rw-r--r-- | activesupport/test/clean_logger_test.rb | 9 |
5 files changed, 29 insertions, 7 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 319806725d..31882ce0dd 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -4,7 +4,6 @@ * Abbreviate RAILS_ROOT in traces - *1.10.1* (October 19th, 2005) * Update error trace templates [Nicholas Seckar] diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index bd8196c631..35a1a1d6bf 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,4 +1,4 @@ -*1.12.1* (October 19th, 2005) +*SVN* * Keep closer tabs on dirty, loaded, and declared fixtures. #2404 [ryand-ruby@zenspider.com] @@ -12,6 +12,8 @@ * Make all tests runnable on their own. #2521. [Blair Zajac <blair@orcaware.com>] +*1.12.1* (October 19th, 2005) + * Always parenthesize :conditions options so they may be safely combined with STI and constraints. * Correct PostgreSQL primary key sequence detection. #2507 [tmornini@infomania.com] diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 237a713255..4c01cf388c 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,3 +1,7 @@ +*SVN* + +* Set Logger.silencer = false to disable Logger#silence. Useful for debugging fixtures. + * Add title case method to String to do, e.g., 'action_web_service'.titlecase # => 'Action Web Service'. [Marcel Molina Jr.] *1.2.1* (October 19th, 2005) diff --git a/activesupport/lib/active_support/clean_logger.rb b/activesupport/lib/active_support/clean_logger.rb index 330dbb2e46..89dfae8f2f 100644 --- a/activesupport/lib/active_support/clean_logger.rb +++ b/activesupport/lib/active_support/clean_logger.rb @@ -1,12 +1,22 @@ require 'logger' +require File.dirname(__FILE__) + '/class_attribute_accessors' class Logger #:nodoc: + cattr_accessor :silencer + self.silencer = true + # Silences the logger for the duration of the block. def silence(temporary_level = Logger::ERROR) - old_logger_level, self.level = level, temporary_level - yield self - ensure - self.level = old_logger_level + if silencer + begin + old_logger_level, self.level = level, temporary_level + yield self + ensure + self.level = old_logger_level + end + else + yield self + end end private diff --git a/activesupport/test/clean_logger_test.rb b/activesupport/test/clean_logger_test.rb index c5ddc713c2..2ff3fd6832 100644 --- a/activesupport/test/clean_logger_test.rb +++ b/activesupport/test/clean_logger_test.rb @@ -32,7 +32,14 @@ class CleanLoggerTest < Test::Unit::TestCase logger.fatal 'fatal' end - assert_equal "error\nfatal\nerror\nfatal\n", @out.string + # Silencer off. + Logger.silencer = false + @logger.silence do |logger| + logger.warn 'unsilenced' + end + Logger.silencer = true + + assert_equal "error\nfatal\nerror\nfatal\nunsilenced\n", @out.string end end |