Changeset 7739
- Timestamp:
- 10/04/07 19:52:10 (1 year ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/buffered_logger.rb (modified) (3 diffs)
- trunk/activesupport/test/buffered_logger_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r7736 r7739 3 3 * Hash#to_json takes :only or :except options to specific or omit certain hash keys. Enumerable#to_json passes through its options to each element. #9751 [Chu Yeow] 4 4 5 * BufferedLogger#auto_flushing = N flushes the log every N messages. Buffers with an array instead of string. [Jeremy Kemper]5 * BufferedLogger#auto_flushing = N flushes the log every N messages. Buffers with an array instead of string. Disabling auto_flushing still flushes when the buffer hits a maximum size, as a failsafe against memory-gobbling. [Jeremy Kemper] 6 6 7 7 * Fixed Date#xmlschema for dates outside the range of what can be created with Time #9744 [Geoff Buesing] trunk/activesupport/lib/active_support/buffered_logger.rb
r7734 r7739 11 11 end 12 12 include Severity 13 14 MAX_BUFFER_SIZE = 1000 13 15 14 16 # Set to false to disable the silencer … … 58 60 message = "#{message}\n" unless message[-1] == ?\n 59 61 @buffer << message 60 auto_flush if auto_flushing62 auto_flush 61 63 message 62 64 end … … 79 81 # flush the log yourself -- it will eat up memory until you do. 80 82 def auto_flushing=(period) 81 case period 82 when true 83 @auto_flushing = 1 84 when 0 85 @auto_flushing = false 86 when false, nil, Integer 87 @auto_flushing = period 88 else 89 raise ArgumentError, "Unrecognized auto_flushing period: #{period.inspect}" 90 end 83 @auto_flushing = 84 case period 85 when true; 1 86 when false, nil, 0; MAX_BUFFER_SIZE 87 when Integer; period 88 else raise ArgumentError, "Unrecognized auto_flushing period: #{period.inspect}" 89 end 91 90 end 92 91 trunk/activesupport/test/buffered_logger_test.rb
r7732 r7739 72 72 assert !@output.string.empty?, @logger.buffer.size 73 73 end 74 75 define_method "test_disabling_auto_flush_with_#{disable.inspect}_should_flush_at_max_buffer_size_as_failsafe" do 76 @logger.auto_flushing = disable 77 assert_equal ActiveSupport::BufferedLogger::MAX_BUFFER_SIZE, @logger.auto_flushing 78 79 (ActiveSupport::BufferedLogger::MAX_BUFFER_SIZE - 1).times do 80 @logger.info 'wait for it..' 81 assert @output.string.empty?, @output.string 82 end 83 84 @logger.info 'there it is.' 85 assert !@output.string.empty?, @logger.buffer.size 86 end 74 87 end 75 88