Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 2553

Show
Ignore:
Timestamp:
10/13/05 19:05:32 (4 years ago)
Author:
bitsweat
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r2512 r2553  
    11*SVN* 
     2 
     3* Fix Logger compatibility for distributions that don't keep Ruby and its standard library in sync. 
    24 
    35* Replace '%e' from long and short time formats as Windows does not support it. #2344. [Tom Ward <tom@popdog.net>] 
  • trunk/activesupport/lib/active_support/clean_logger.rb

    r2369 r2553  
    55  def silence(temporary_level = Logger::ERROR) 
    66    old_logger_level, self.level = level, temporary_level 
    7     yield 
     7    yield self 
    88  ensure 
    99    self.level = old_logger_level 
     
    1111 
    1212  private 
    13     # Ruby 1.8.3 swapped the format_message params. 
    14     if RUBY_VERSION < '1.8.3' 
    15       def format_message(severity, timestamp, msg, progname) 
     13    # Ruby 1.8.3 transposed the msg and progname arguments to format_message. 
     14    # We can't test RUBY_VERSION because some distributions don't keep Ruby 
     15    # and its standard library in sync, leading to installations of Ruby 1.8.2 
     16    # with Logger from 1.8.3 and vice versa. 
     17    if method_defined?(:formatter=) 
     18      def format_message(severity, timestamp, progname, msg) 
    1619        "#{msg}\n" 
    1720      end 
    1821    else 
    19       def format_message(severity, timestamp, progname, msg
     22      def format_message(severity, timestamp, msg, progname
    2023        "#{msg}\n" 
    2124      end