From: eldy <> Date: Fri, 9 Nov 2001 15:18:06 +0000 (+0000) Subject: Make better log informations. X-Git-Tag: AWSTATS_1_0~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbcc055e51bfbf3765b30e394e9cfa459006c272;p=thirdparty%2FAWStats.git Make better log informations. --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 593a7c08..f75e3634 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -45,7 +45,7 @@ # ---------- Init variables (Variable $TmpHashxxx are not initialized) -------- ($AddOn, $ArchiveFileName, $ArchiveLogRecords, $KeepBackupOfHistoricFiles, $BarHeight, $BarWidth, -$DIR, $DNSLookup, $DayRequired, $Debug, $DefaultFile, +$DEBUGRESET, $DIR, $DNSLookup, $DayRequired, $Debug, $DefaultFile, $DirCgi, $DirData, $DirIcons, $DirLang, $DetailedReportsOnNewWindows, $Expires, $Extension, $FileConfig, $FileSuffix, $FirstDayOfWeek, $FirstTime, $HTMLHeadSection, $HTMLEndSection, $Host, $KeepBackupOfHistoricFiles, @@ -82,10 +82,11 @@ $WarningMessages= 1; %MonthBytes = %MonthHits = %MonthHostsKnown = %MonthHostsUnknown = %MonthPages = %MonthUnique = %MonthVisits = %monthlib = %monthnum = (); -$VERSION="3.2 (build 49)"; +$VERSION="3.2 (build 51)"; $Lang="en"; # Default value +$DEBUGFORCED = 0; # Force debug level to log lesser level into debug.log file (Keep this value to 0) $MAXROWS = 200000; # Max number of rows for not limited HTML arrays $SortDir = -1; # -1 = Sort order from most to less, 1 = reverse order (Default = -1) $VisitTimeOut = 10000; # Laps of time to consider a page load as a new visit. 10000 = one hour (Default = 10000) @@ -255,7 +256,7 @@ sub error { my $message=shift; my $secondmessage=shift; my $thirdmessage=shift; - + debug("$message $secondmessage $thirdmessage",1); if ($message =~ /^Format error$/) { # Files seems to have bad format if ($HTMLOutput) { print "

\n"; } @@ -315,8 +316,9 @@ sub error { } sub warning { + my $messagestring=shift; + debug("$messagestring",1); if ($WarningMessages == 1) { - my $messagestring=$_[0]; if ($HTMLOutput) { $messagestring =~ s/\n/\/g; print "$messagestring
\n"; @@ -327,12 +329,23 @@ sub warning { } } +# Parameters : $string $level +# Input : $Debug = required level $DEBUGFORCED = required level forced sub debug { my $level = $_[1] || 1; + if ($DEBUGFORCED >= $level) { + my $debugstring = $_[0]; + if ($DEBUGFORCED >= $level) { + if ($DEBUGRESET == 0) { open(DEBUGFORCEDFILE,"debug.log"); close DEBUGFORCEDFILE; chmod 0666,"debug.log"; $DEBUGRESET=1; } + open(DEBUGFORCEDFILE,">>debug.log"); + print DEBUGFORCEDFILE localtime(time)." - $$ - $DEBUG $level - $debugstring\n"; + close DEBUGFORCEDFILE; + } + } if ($Debug >= $level) { my $debugstring = $_[0]; if ($HTMLOutput) { $debugstring =~ s/^ /   /; $debugstring .= "
"; } - print "DEBUG $level - ".time." : $debugstring\n"; + print localtime(time)." - DEBUG $level - $debugstring\n"; } } @@ -849,7 +862,9 @@ sub Read_History_File { my $year=sprintf("%04i",shift); my $month=sprintf("%02i",shift); my $part=shift; - &debug("Call to Read_History_File [$year,$month,$part] ($DayRequired)"); # In standard use of AWStats, the DayRequired variable is always empty + # In standard use of AWStats, the DayRequired variable is always empty + if ($DayRequired) { &debug("Call to Read_History_File [$year,$month,$part] ($DayRequired)"); } + else { &debug("Call to Read_History_File [$year,$month,$part]"); } if ($HistoryFileAlreadyRead{"$year$month$DayRequired"}) { # Protect code to invoke function only once for each month/year &debug(" Already loaded"); return 0; @@ -1659,9 +1674,6 @@ $NewDNSLookup=$DNSLookup; # monthnum must be in english because it's used to translate log date in apache log files which are always in english %monthnum = ( "Jan","01","jan","01","Feb","02","feb","02","Mar","03","mar","03","Apr","04","apr","04","May","05","may","05","Jun","06","jun","06","Jul","07","jul","07","Aug","08","aug","08","Sep","09","sep","09","Oct","10","oct","10","Nov","11","nov","11","Dec","12","dec","12" ); -$BrowsersHashIDLib{"netscape"}="Netscape ($Message[58])"; -$BrowsersHashIDLib{"msie"}="MS Internet Explorer ($Message[58])"; - # Init all global variables if (! @HostAliases) { warning("Warning: HostAliases parameter is not defined, $PROG choose \"$SiteToAnalyze localhost 127.0.0.1\"."); @@ -3282,6 +3294,8 @@ EOF # BY BROWSER #---------------------------- if ($ShowBrowsersStats) { + $BrowsersHashIDLib{"netscape"}="Netscape ($Message[58])"; + $BrowsersHashIDLib{"msie"}="MS Internet Explorer ($Message[58])"; my $Total=0; foreach my $key (keys %_browser_h) { $Total+=$_browser_h{$key}; } print "$CENTER 
"; &tab_head($Message[21],19);