in reply to naming conventions for logs
If you don't mind a wee bit of overhead you can try running your logfile names through stftime. You can give your logfiles names like myprogram-%Y-%m-%d.log and as long as you perform your open-append each time when you go to write, and your files will be nicely broken into days for you.
This will give you logfiles with names like program-2002-08-05.log (which will sort correctly) and each line will be prefixed by a HH:MM:SS timestamp. Then you could delete last month's logs with a rm *-2002-08-??.log or the like.use POSIX qw/strftime/; # Main routine... my $logfile = "program-%Y-%m-%d.log"; &do_log($logfile, "This is the message I want to log"); sub do_log { my $logfile = shift; my $message = shift; open LOG, ">>".strftime($logfile, localtime); print LOG stftime("%H:%M:%S ", localtime); print LOG $message,"\n"; close LOG; }
Of course you may wish to make your logging routine a bit more sophisticated than this. (Some error checking would be nice, of course.)
Good luck,
{NULE}
--
http://www.nule.org
|
|---|