class Logging::Appenders::RollingFile::DateRoller
Simple patch to DateRoller
which uses the previous day’s date for the rolled filename
oneliner to fix incorrect dates from previously rolled files: ruby -rtime -e ‘`ls .2.log`.split(“n”).each{ |f| f =~ /(2015d+)/; d = $1; dd = (Time.parse(d)-86400).strftime(“%Y%m%d”); File.rename(f, f.gsub(/#{d}/, dd)) }’
Public Instance Methods
roll_files()
click to toggle source
# File lib/bixby-common/util/log/logger.rb, line 34 def roll_files return unless @roll and ::File.exist?(@fn_copy) # rename the copied log file ::File.rename(@fn_copy, (Time.now-86400).strftime(@logname_fmt)) # prune old log files if @keep files = Dir.glob(@glob).find_all {|fn| @rgxp =~ fn} length = files.length if length > @keep files.sort {|a,b| b <=> a}.last(length-@keep).each {|fn| ::File.delete fn} end end ensure @roll = false end