chiark / gitweb /
Merge remote branch 'origin/master'
[modbot-uram.git] / webstump / scripts / html_output.pl
index bf6707d3ca28ede815bb767103d661c257996d3b..728bd711d42fd3c153b1598b09598af096318da5 100644 (file)
@@ -635,22 +635,24 @@ sub scanlogs ($$$) {
     my $num= sub {
         local ($_) = @_;
         return $forwards * (
-            m/^errs$/ ? -1 :
-            m/^errs\.(\d+)(?:\.gz$)$/ ? $1 :
-            undef
+            m/^errs$/ ? 1 :
+            m/^errs\.(\d+)(?:\.gz$)$/ ? ($1+2) :
+            0
                            );
     };
     foreach my $leaf (
                       sort { $num->($a) <=> $num->($b) }
-                      grep { defined $num->($_) }
+                     grep { $num->($_) }
                       readdir LOGSDIR
                       ) {
         my $file= "$dir/$leaf";
-        if ($file =~ m/\.gz$/) {
-            open LOGFILE, "zcat $file |" or die "zcat $file $!";
+        if ($file =~ m/\/errs.*\.gz$/) {
+            open LOGFILE, "zcat $file | tac |" or die "zcat $file | tac $!";
+        } elsif ($file =~ /errs/) {
+            open LOGFILE, "tac $file |" or die "tac $file $!";
         } else {
-            open LOGFILE, "< $file" or die "$file $!";
-        }
+           die "Unexpected filename in scanlogs: $file";
+       }
         while (<LOGFILE>) {
             my $tgot= $callback->();
             next unless $tgot;