]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
NEW add %time6 tag in log format to support some IIS log format
authorLaurent Destailleur <eldy@destailleur.fr>
Fri, 30 Aug 2019 11:24:55 +0000 (13:24 +0200)
committerLaurent Destailleur <eldy@destailleur.fr>
Fri, 30 Aug 2019 11:24:55 +0000 (13:24 +0200)
wwwroot/cgi-bin/awstats.model.conf
wwwroot/cgi-bin/awstats.pl

index 95a7fe54388a96894a9242dcb6a6d14467de165e..71bb97d9813b80f88050858ba218f8d72c05a9ab 100644 (file)
@@ -83,6 +83,7 @@ LogType=W
 #   %time3            Date and time with format: Mon dd hh:mm:ss or Mon dd hh:mm:ss yyyy
 #   %time4            Date and time with unix timestamp format: dddddddddd
 #   %time5            Date and time with format iso: yyyy-mm-ddThh:mm:ss, with optional timezone specification (ignored)
+#   %time6            Date and time with format: dd/mm/yyyy, hh:mm:ss
 #   %methodurl        Method and URL with format: "GET /index.html HTTP/x.x"
 #   %methodurlnoprot  Method and URL with format: "GET /index.html"
 #   %method           Method with format: GET
index 796521c6e23898b3e896cbfe591d7ec9d3b182fe..7ec5125290b25fbeb40fd1d234b84241fe8fc153 100755 (executable)
@@ -9186,6 +9186,12 @@ sub DefinePerlParsingFormat {
                                $PerlParsingFormat .=
 "([^$LogSeparatorWithoutStar]+T[^$LogSeparatorWithoutStar]+)(Z|[-+\.]\\d\\d[:\\.\\dZ]*)?";
                        }
+                       elsif ( $f =~ /%time6$/ ) {     # dd/mm/yyyy, hh:mm:ss - added additional type to format for IIS date -DWG 12/8/2008
+                               $pos_date = $i; 
+                               $i++; 
+                               push @fieldlib, 'date';
+                               $PerlParsingFormat .= "([^,]+,[^,]+)";
+                       }
 
                        # Special for methodurl, methodurlprot and methodurlnoprot
                        elsif ( $f =~ /%methodurl$/ ) {
@@ -18415,6 +18421,25 @@ if ( $UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft' )
                        next;
                }
 
+               # Reformat date for IIS date -DWG 12/8/2008
+               if($field[$pos_date] =~ /,/)
+               {
+                       $field[$pos_date] =~ s/,//;
+                       my @split_date = split(' ',$field[$pos_date]);
+                       my @dateparts2= split('/',$split_date[0]);
+                       my @timeparts2= split(':',$split_date[1]);
+                       #add leading zero
+                       for($dateparts2[0],$dateparts2[1], $timeparts2[0], $timeparts2[1],  $timeparts2[2])                     {
+                               if($_ =~ /^.$/)
+                               {
+                                       $_ = '0'.$_;
+                               }
+
+                       }
+
+                       $field[$pos_date] = "$dateparts2[2]-$dateparts2[0]-$dateparts2[1] $timeparts2[0]:$timeparts2[1]:$timeparts2[2]";
+               }
+               
                $field[$pos_date] =~
                  tr/,-\/ \tT/::::::/s;  # " \t" is used instead of "\s" not known with tr
                my @dateparts =