[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rev it up (mistake in log cycler)



Sorry 'bout this but the first `Rev it up` had the wrong log cycling
code and people have been asking for it so here is a re-posting of it.
First off, cycling the log file to the day it was made instead of one
huge log file.  This code will make new logs daily by date looking
something like: 16Jan2000-infobot.log
You just add this code but change the directory from
/usr/infobot/logs/$date to /wherever/you/store/logs/$date
You will need to change this in src/Misc.pl so here it is:

(line 5 after use Socket;): use POSIX qw(strftime);
Remove lines 124-146 ( sub log_line --- }) and put this in instead:
####################
sub log_line {
$day = strftime "%d%b%Y-", localtime;
$date = "$day" . "$param{logfile}";
my($line) = @_;
my($logwrite) = 0;
my $s = time();
if ($param{'logfile'} ne '') {
$line =~ s/\n*$/\n/;
open(TRACK, ">>/usr/infobot/logs/$date");
$loglines++;
$total_loglines++;
print TRACK "$s $line";
close(TRACK);           #  if (TRACK);
}
}
#####################

Sorry everyone, hope you can make use of this.
-Sam (CommPort5)