Skip to content

Instantly share code, notes, and snippets.

@chrismo
Last active December 15, 2015 15:28
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 chrismo/5281592 to your computer and use it in GitHub Desktop.
Save chrismo/5281592 to your computer and use it in GitHub Desktop.
require 'tmpdir'
def setup
dir = Dir::tmpdir
%w(system.log 20130330.log 20130329.log).each do |fn|
File.open(fn, 'w') { |f| f.print 'fake contents' }
end
end
def rotate_logs
log_filenames = Dir[File.join(Dir::tmpdir, '*.log')]
rename_latest(log_filenames)
delete_oldest(log_filenames)
end
def rename_latest(log_filenames)
# code to rename the latest
end
def delete_oldest(log_filenames)
# code to delete the latest
end
setup
rotate_logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment