From: Fabian Keil <fk@fabiankeil.de>
Date: Sat, 28 Aug 2010 13:22:00 +0000 (+0000)
Subject: Display a warning if the URL statistics are incomplete or skipped.
X-Git-Tag: v_3_0_17~96
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/faq/@default-cgi@/@default-cgi@send-stylesheet?a=commitdiff_plain;h=0b56bba796223c4b7e32822266b0c2a98cae25f2;p=privoxy.git

Display a warning if the URL statistics are incomplete or skipped.
---

diff --git a/tools/privoxy-log-parser.pl b/tools/privoxy-log-parser.pl
index 8a9b98df..a8797ae2 100755
--- a/tools/privoxy-log-parser.pl
+++ b/tools/privoxy-log-parser.pl
@@ -8,7 +8,7 @@
 #
 # http://www.fabiankeil.de/sourcecode/privoxy-log-parser/
 #
-# $Id: privoxy-log-parser.pl,v 1.90 2010/08/28 13:20:52 fabiankeil Exp $
+# $Id: privoxy-log-parser.pl,v 1.91 2010/08/28 13:21:24 fabiankeil Exp $
 #
 # TODO:
 #       - LOG_LEVEL_CGI, LOG_LEVEL_ERROR, LOG_LEVEL_WRITE content highlighting
@@ -2003,10 +2003,18 @@ sub print_stats () {
     foreach my $http_version (sort {$stats{'http-version'}{$b} <=> $stats{'http-version'}{$a}} keys %{$stats{'http-version'}}) {
         printf "%d : %s\n",  $stats{'http-version'}{$http_version}, $http_version;
     }
-    print "Requested ressources:\n";
-    foreach my $ressource (sort {$stats{'ressource'}{$b} <=> $stats{'ressource'}{$a}} keys %{$stats{'ressource'}}) {
-        last if $stats{'ressource'}{$ressource} < $cli_options{'url-statistics-threshold'};
-        printf "%d : %s\n", $stats{'ressource'}{$ressource}, $ressource;
+
+    if ($cli_options{'url-statistics-threshold'} == 0) {
+        print "URL statistics are disabled. Increase --url-statistics-threshold to enable them.\n";
+    } else {
+        print "Requested URLs:\n";
+        foreach my $ressource (sort {$stats{'ressource'}{$b} <=> $stats{'ressource'}{$a}} keys %{$stats{'ressource'}}) {
+            if ($stats{'ressource'}{$ressource} < $cli_options{'url-statistics-threshold'}) {
+                print "Skipped statistics for URLs below the treshold.\n";
+                last;
+            }
+            printf "%d : %s\n", $stats{'ressource'}{$ressource}, $ressource;
+        }
     }
 }