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

Changeset 7664

Show
Ignore:
Timestamp:
09/28/07 14:09:35 (9 months ago)
Author:
bitsweat
Message:

BufferedLogger#add converts the message to a string. Closes #9724.

Files:

Legend:

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

    r7658 r7664  
    55* Backport Object#instance_variable_defined? for Ruby < 1.8.6.  [Jeremy Kemper] 
    66 
    7 * BufferedLogger#add doesn't modify the message argument.  #9702 [eigentone
     7* BufferedLogger#add converts the message to a string.  #9702, #9724 [eigentone, DrMark, tomafro
    88 
    99* Added ActiveSupport::BufferedLogger as a duck-typing alternative (albeit with no formatter) to the Ruby Logger, which provides a very nice speed bump (inspired by Ezra's buffered logger) [DHH] 
  • trunk/activesupport/lib/active_support/buffered_logger.rb

    r7645 r7664  
    5252    def add(severity, message = nil, progname = nil, &block) 
    5353      return if @level > severity 
    54       message = message || (block && block.call) || progname 
     54      message = (message || (block && block.call) || progname).to_s 
    5555      # If a newline is necessary then create a new message ending with a newline. 
    5656      # Ensures that the original message is not mutated. 
  • trunk/activesupport/test/buffered_logger_test.rb

    r7643 r7664  
    55  def setup 
    66    @message = "A debug message" 
     7    @integer_message = 12345 
    78    @output  = StringIO.new 
    89    @logger  = ActiveSupport::BufferedLogger.new(@output) 
     
    3334  end 
    3435   
     36  def test_should_convert_message_to_string 
     37    @logger.level = Logger::INFO 
     38    @logger.info @integer_message 
     39    assert @output.string.include?(@integer_message.to_s) 
     40  end 
     41   
     42  def test_should_convert_message_to_string_when_passed_in_block 
     43    @logger.level = Logger::INFO 
     44    @logger.info {@integer_message} 
     45    assert @output.string.include?(@integer_message.to_s) 
     46  end 
     47   
    3548  def test_should_not_evaluate_block_if_message_wont_be_logged 
    3649    @logger.level = Logger::INFO