From: Fabian Keil Date: Sat, 6 Nov 2010 13:27:45 +0000 (+0000) Subject: Fix some possible warnings by setting all known undefined stats keys to zero before... X-Git-Tag: v_3_0_17~42 X-Git-Url: http://www.privoxy.org/gitweb/actions-file.html?a=commitdiff_plain;h=dbe204ff3ce4a8d9bda858d6efe69564502ab73f;p=privoxy.git Fix some possible warnings by setting all known undefined stats keys to zero before generating the statistics. --- diff --git a/tools/privoxy-log-parser.pl b/tools/privoxy-log-parser.pl index 1a914dd6..977b5067 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.96 2010/10/23 08:01:54 fabiankeil Exp $ +# $Id: privoxy-log-parser.pl,v 1.97 2010/11/06 12:10:29 fabiankeil Exp $ # # TODO: # - LOG_LEVEL_CGI, LOG_LEVEL_ERROR, LOG_LEVEL_WRITE content highlighting @@ -1966,6 +1966,19 @@ sub get_percentage ($$) { return sprintf("%.2f%%", $small / $big * 100); } +sub set_undefined_stats_keys_to_zero () { + our %stats; + my @known_stats_keys = ( + 'requests', 'crunches', 'fast-redirections', 'blocked', + 'empty-responses', 'empty-responses-on-new-connections', + 'empty-responses-on-reused-connections', 'reused-connections', + 'server-keep-alive'); + + foreach my $known_key (@known_stats_keys) { + $stats{$known_key} = 0 unless defined $stats{$known_key}; + } +} + sub print_stats () { our %stats; @@ -2240,6 +2253,7 @@ sub stats_loop () { } } + set_undefined_stats_keys_to_zero(); print_stats(); }