vendor/gems/logging-0.9.7/lib/logging/appenders/rolling_file.rb
# call-seq:
#    roll_files
#
# Roll the log files. This is accomplished by renaming the log files
# starting with the oldest and working towards the youngest.
#
#    test.10.log  =>  deleted (we are only keeping 10)
#    test.9.log   =>  test.10.log
#    test.8.log   =>  test.9.log
#    ...
#    test.1.log   =>  test.2.log
#    
# Lastly the current log file is rolled to a numbered log file.
#
#    test.log     =>  test.1.log
#
# This method leaves no <tt>test.log</tt> file when it is done. This
# file will be created elsewhere.
#


Roll the log files. This is accomplished by renaming the log files
starting with the oldest and working towards the youngest.



Lastly the current log file is rolled to a numbered log file.



This method leaves no test.log file when it is done. This
file will be created elsewhere.
Roll the log files . This is accomplished by renaming the log files starting with the oldest and working towards the youngest . Lastly the current log file is rolled to a numbered log file . This method leaves no test . log file when it is done . This file will be created elsewhere .
def roll_files
      return unless ::File.exist?(@fn)
      files = Dir.glob(@glob).find_all {|fn| @rgxp =~ fn}
      unless files.empty?
        files = files.sort do |a,b|
                  a = Integer(@rgxp.match(a)[1])
                  b = Integer(@rgxp.match(b)[1])
                  b <=> a
                end
        files.each do |fn|
          cnt = Integer(@rgxp.match(fn)[1])
          if @keep and cnt >= @keep
            ::File.delete fn
            next
          end
          ::File.rename fn, sprintf(@logname_fmt, cnt+1)
        end
      end
      ::File.rename(@fn, sprintf(@logname_fmt, 1))
      FileUtils.touch(@age_fn) if @age
    end
def roll_files return unless :: File . exist? ( @fn ) files = Dir . glob ( @glob ) . find_all { | fn | @rgxp =~ fn } unless files . empty? files = files . sort do | a , b | a = Integer ( @rgxp . match ( a ) [ 1 ] ) b = Integer ( @rgxp . match ( b ) [ 1 ] ) b <=> a end files . each do | fn | cnt = Integer ( @rgxp . match ( fn ) [ 1 ] ) if @keep and cnt >= @keep :: File . delete fn next end :: File . rename fn , sprintf ( @logname_fmt , cnt + 1 ) end end :: File . rename ( @fn , sprintf ( @logname_fmt , 1 ) ) FileUtils . touch ( @age_fn ) if @age end
call-seq:
roll_files
call - seq : roll_files
# sort the files in revese order based on their count number # for each file, roll its count number one higher # finally reanme the base log file # touch the age file if needed