Last active
December 15, 2015 15:28
-
-
Save chrismo/5281592 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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