]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Add various tags to use dynamic log file name in conf file according to current but...
authoreldy <>
Wed, 28 Nov 2001 01:30:39 +0000 (01:30 +0000)
committereldy <>
Wed, 28 Nov 2001 01:30:39 +0000 (01:30 +0000)
wwwroot/cgi-bin/awstats.model.conf
wwwroot/cgi-bin/awstats.pl

index 88a2755776b201dc4dcac110449f6cc2ae276b66..b90901af2346b311a102b99539238eca1e629c2e 100644 (file)
 # MAIN SETUP SECTION (Required to make AWStats working)
 #------------------------------------------------------------------------
 
-# "LogFile" contains the web server logfile name to analyze.
-# You can use a full path...
+# "LogFile" contains the web server logfile to analyze.
+# You can use a full path or relative path from awstats.pl directory.
 # Example: "/var/log/apache/access.log"
-# or relative path from awstats.pl directory...
 # Example: "../logs/mycombinedlog.log"
 #
-# You can also use %YY %MM %DD %HH or %WM in file name, AWStats will
-# replace those tags with current year month day hour or
-# week of month.
-# Example: "C:/WINNT/system32/LogFiles/W3SVC1/ex%YY%MM%DD.log"
+# You can also use tags in this filename if you need a dynamic file name
+# depending on date or time (Replacement is made by AWStats at the beginning
+# of its execution). This is available tags :
+# %YYYY-n  is replaced with 4 digits year we were n hours ago
+# %YY-n    is replaced with 2 digits year we were n hours ago
+# %MM-n    is replaced with month we were n hours ago
+# %DD-n    is replaced with day we were n hours ago
+# %HH-n    is replaced with hour we were n hours ago
+# %WM-n    is replaced with the week number in month (1-5)
+# You can use n=0 if you need current year, month, day, hour...
+# Example: "/var/log/access_log.%YYYY-24%MM-24%DD-24.log"
+# Example: "C:/WINNT/system32/LogFiles/W3SVC1/ex%YY-0%MM-0%DD-0.log"
 #
 LogFile="/var/log/httpd/mylog.log"
 
@@ -189,7 +196,7 @@ ArchiveLogRecords=0
 KeepBackupOfHistoricFiles=0
 
 # Set your primary language.
-# Possible value:
+#  Possible value:
 # Bosnian=ba, Chinese (Taiwan)=tw, Chinese (Traditional)=cn, Czech=cz,
 # Danish=dk, Dutch=nl, English=en, French=fr, German=de, Greek=gr,
 # Hungarian=hu, Indonesian=id, Italian=it, Japanese=jp, Korean=kr,
index a1bf0cdde7aade442c94632d4b5f040f46e4067b..c55106c8cd24bc9cf56b086f9cc7a55ebfa49729 100644 (file)
@@ -82,7 +82,7 @@ $WarningMessages= 1;
 %MonthBytes = %MonthHits = %MonthHostsKnown = %MonthHostsUnknown = %MonthPages = %MonthUnique = %MonthVisits =
 %monthlib = %monthnum = ();
 
-$VERSION="3.2 (build 65)";
+$VERSION="3.2 (build 66)";
 $Lang="en";
 
 # Default value
@@ -424,13 +424,38 @@ sub Read_Config_File {
                # Read main section
                if ($param =~ /^LogFile/) {
                        $LogFile=$value;
-                       # Replace %YYYY %YY %MM %DD %HH with current value
+                       if ($LogFile =~ /%([YMDH]+)-(\d*)/) {
+                               my $timephase=$2;
+                               debug(" Found a time phase of $timephase hour in log file name",1);
+                               # Get older time
+                               ($oldersec,$oldermin,$olderhour,$olderday,$oldermonth,$olderyear,$olderwday) = localtime($nowtime-($timephase*3600));
+                               $olderweekofmonth=int($olderday/7);
+                               $olderdaymod=$olderday%7;
+                               $olderwday++;
+                               if ($olderdaymod <= $olderwday) { if (($olderwday != 7) || ($olderdaymod != 0)) { $olderweekofmonth=$olderweekofmonth+1; } }
+                               if ($olderdaymod >  $olderwday) { $olderweekofmonth=$olderweekofmonth+2; }
+                               if ($olderyear < 100) { $olderyear+=2000; } else { $olderyear+=1900; }
+                               $oldersmallyear=$olderyear;$oldersmallyear =~ s/^..//;
+                               if (++$oldermonth < 10) { $oldermonth = "0$oldermonth"; }
+                               if ($olderday < 10) { $olderday = "0$olderday"; }
+                               if ($olderhour < 10) { $olderhour = "0$olderhour"; }
+                               if ($oldermin < 10) { $oldermin = "0$oldermin"; }
+                               if ($oldersec < 10) { $oldersec = "0$oldersec"; }
+                               $LogFile =~ s/%YYYY-$timephase/$olderyear/g;
+                               $LogFile =~ s/%YY-$timephase/$oldersmallyear/g;
+                               $LogFile =~ s/%MM-$timephase/$oldermonth/g;
+                               $LogFile =~ s/%DD-$timephase/$olderday/g;
+                               $LogFile =~ s/%HH-$timephase/$olderhour/g;
+                               $LogFile =~ s/%WM-$timephase/$olderweekofmonth/g;
+                       }
+                       # Replace %YYYY %YY %MM %DD %HH with current value. Kept for backward compatibility.
                        $LogFile =~ s/%YYYY/$nowyear/g;
                        $LogFile =~ s/%YY/$nowsmallyear/g;
                        $LogFile =~ s/%MM/$nowmonth/g;
                        $LogFile =~ s/%DD/$nowday/g;
                        $LogFile =~ s/%HH/$nowhour/g;
                        $LogFile =~ s/%WM/$nowweekofmonth/g;
+                       debug(" LogFile=$LogFile",1);
                        next;
                        }
                if ($param =~ /^LogFormat/)             { $LogFormat=$value; next; }