Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Logging::Appenders::TimestampRollingFile < Logging::Appenders::RollingFile
def initialize( name, opts = {} )
super
@date_fmt = '%Y%m%d'
@logname_fmt.sub!(%r/\.%d/, '.%s')
end
def roll_files
return unless ::File.exist?(@fn)
# rename the base log file
::File.rename(@fn, sprintf(@logname_fmt, Time.now.strftime(@date_fmt)))
# touch the age file if needed
FileUtils.touch(@age_fn) if @age
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment