Project

General

Profile

Feature #11955 ยป ruby-changes.patch

schneems (Richard Schneeman), 01/19/2016 08:02 PM

View differences:

ChangeLog
1
Tue Jan  5 21:45:12 2016  Richard Schneeman <richard.schneeman@gmail.com>
2

  
3
	* lib/logger.rb add method Logger#destination
4

  
1 5
Tue Jan  5 21:44:37 2016  SHIBATA Hiroshi  <hsbt@ruby-lang.org>
2 6

  
3 7
	* ChangeLog: fix wrong class name.
lib/logger.rb
271 271
    end
272 272
  end
273 273

  
274
  # Returns the <tt>Logger::LogDevice</tt> responsible for logging messages.
275
  attr_reader :logdev
276

  
274 277
  # Program name to include in log messages.
275 278
  attr_accessor :progname
276 279

  
......
625 628
  class LogDevice
626 629
    include Period
627 630

  
631
    # The destination object that will receive the log message.
628 632
    attr_reader :dev
629 633
    attr_reader :filename
630 634
    include MonitorMixin
631 635

  
636
    #
637
    # :call-seq:
638
    #   Logger::Logdev.new(STDOUT)
639
    #   Logger::Logdev.new('test.log')
640
    #   Logger::Logdev.new('test.log', shift_age: 'weekly')
641
    #   Logger::Logdev.new('test.log', shift_age: 7, shift_size: 1048576)
642
    #
643
    # === Args
644
    #
645
    # +log+::
646
    #   The log destination.  This is a filename (String) or IO object (typically
647
    #   +STDOUT+, +STDERR+, or an open file).
648
    # +opt+::
649
    #   A hash of options
650
    #   - +shift_age+
651
    #     Number of old log files to keep, *or* frequency of rotation (+daily+,
652
    #     +weekly+ or +monthly+).
653
    #   - +shift_size+::
654
    #     Maximum logfile size (only applies when +shift_age+ is a number).
655
    #
656
    # === Description
657
    #
658
    # Create an instance.
659
    #
632 660
    def initialize(log = nil, opt = {})
633 661
      @dev = @filename = @shift_age = @shift_size = nil
634 662
      mon_initialize
test/logger/test_logger.rb
292 292
    r.close
293 293
    assert_equal("msg2\n\n", msg)
294 294
  end
295

  
296
  def test_logdev_and_destination
297
    r, w = IO.pipe
298
    logger = Logger.new(w)
299
    assert_equal(w, logger.logdev.dev)
300
  end
295 301
end