Skip to content

Instantly share code, notes, and snippets.

@TwP
Created December 23, 2008 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TwP/39362 to your computer and use it in GitHub Desktop.
Save TwP/39362 to your computer and use it in GitHub Desktop.
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