diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-10-13 19:05:32 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-10-13 19:05:32 +0000 |
commit | 9c8227973cd5fc00f1df199756220712ae78f6dc (patch) | |
tree | f7e379dbf4051c9092987cc51e89a6437d2515e0 /activesupport/lib/active_support/clean_logger.rb | |
parent | 634da0f0102693fbb034b3b7b17808fa5afeb66a (diff) | |
download | rails-9c8227973cd5fc00f1df199756220712ae78f6dc.tar.gz rails-9c8227973cd5fc00f1df199756220712ae78f6dc.tar.bz2 rails-9c8227973cd5fc00f1df199756220712ae78f6dc.zip |
r3574@sedna: jeremy | 2005-10-13 11:16:51 -0700
More precise Logger version test to account for distributions that don't keep Ruby and its stdlib in sync. Logger#silence yields self for convenience. Logger unit tests.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2553 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/clean_logger.rb')
-rw-r--r-- | activesupport/lib/active_support/clean_logger.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/clean_logger.rb b/activesupport/lib/active_support/clean_logger.rb index 07162f1d44..330dbb2e46 100644 --- a/activesupport/lib/active_support/clean_logger.rb +++ b/activesupport/lib/active_support/clean_logger.rb @@ -4,19 +4,22 @@ class Logger #:nodoc: # Silences the logger for the duration of the block. def silence(temporary_level = Logger::ERROR) old_logger_level, self.level = level, temporary_level - yield + yield self ensure self.level = old_logger_level end private - # Ruby 1.8.3 swapped the format_message params. - if RUBY_VERSION < '1.8.3' - def format_message(severity, timestamp, msg, progname) + # Ruby 1.8.3 transposed the msg and progname arguments to format_message. + # We can't test RUBY_VERSION because some distributions don't keep Ruby + # and its standard library in sync, leading to installations of Ruby 1.8.2 + # with Logger from 1.8.3 and vice versa. + if method_defined?(:formatter=) + def format_message(severity, timestamp, progname, msg) "#{msg}\n" end else - def format_message(severity, timestamp, progname, msg) + def format_message(severity, timestamp, msg, progname) "#{msg}\n" end end |