X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Flogger.pl;h=ad72e08252acc95717a52d8e8d592a0b4912e125;hb=5d11520e48da367aec87b2ee6621ff6e33c9236b;hp=cd94341d9d8a366e5fd7e33c04cd21fb05f2aef3;hpb=d71caaa9e4c27a4210c37e91d6f7bc3be2fe7cb5;p=infobot.git diff --git a/src/logger.pl b/src/logger.pl index cd94341..ad72e08 100644 --- a/src/logger.pl +++ b/src/logger.pl @@ -1,15 +1,15 @@ # # logger.pl: logger functions! # Author: dms -# Version: v0.3 (20000731) +# Version: v0.4 (20000923) # FVersion: 19991205 # NOTE: Based on code by Kevin Lenzo & Patrick Cole (c) 1997 # use strict; -use vars qw($logDate $loggingstatus $statcount $bot_pid $forkedtime - $statcountfix $addressed $logcount $logtime); +use vars qw($statcount $bot_pid $forkedtime $statcountfix $addressed); +use vars qw($logDate $logold $logcount $logtime $logrepeat); use vars qw(@backlog); use vars qw(%param %file); @@ -17,6 +17,10 @@ require 5.001; $logtime = time(); $logcount = 0; +$logrepeat = 0; +$logold = ""; + +$param{VEBOSITY} ||= 1; # lame fix for preload my %attributes = ( 'clear' => 0, @@ -97,21 +101,18 @@ sub openLog { if (open(LOG, ">>$file{log}")) { &status("Opened logfile $file{log}."); LOG->autoflush(1); - $loggingstatus = 1; } else { - &status("cannot open logfile $file{log}; disabling."); - $loggingstatus = 0; + &status("cannot open logfile $file{log}; not logging."); } } sub closeLog { # lame fix for paramlogfile. return unless (&IsParam("logfile")); - return unless ($loggingstatus); + return unless (defined fileno LOG); - $loggingstatus = 0; - &status("Closed logfile ($file{log})."); close LOG; + &status("Closed logfile ($file{log})."); } ##### @@ -189,8 +190,31 @@ sub status { my($input) = @_; my $status; - # return if input is null'ish. - return '' if ($input =~ /^\s*$/); + if ($input eq $logold) { + $logrepeat++; + + if ($logrepeat >= 3) { + $logrepeat = 0; + &status("LOG: repeat throttle."); + sleep 1; + } + } + $logold = $input; + + # if it's not a scalar, attempt to warn and fix. + if (ref($input) ne "") { + &status("status: 'input' is not scalar (".ref($input).")."); + if (ref($input) eq "ARRAY") { + foreach (@$input) { + &WARN("status: '$_'."); + } + } + } + + # Something is using this w/ NULL. + if (!defined $input or $input =~ /^\s*$/) { + $input = "Blank status call?"; + } $input =~ s/\n+$//; $input =~ s/\002|037//g; # bold,video,underline => remove. @@ -289,7 +313,7 @@ sub status { # log the line into a file. return unless (&IsParam("logfile")); - return unless ($loggingstatus); + return unless (defined fileno LOG); # remove control characters from logging. $input =~ s/\e\[[0-9;]+m//g;