X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=tools%2Fprivoxy-log-parser.pl;h=12f8af82afd8e13ab71e6fb2927408a18674506f;hb=70b9ed04dec24ef32a00a14dbe2a1556275e9bd3;hp=f108f79d24b26fe7ab34e237ca8734a2ebda4707;hpb=8ca522f4ee3c49bdffd79792a86caf447a8ea9f5;p=privoxy.git diff --git a/tools/privoxy-log-parser.pl b/tools/privoxy-log-parser.pl index f108f79d..12f8af82 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.215 2009/12/30 14:23:44 fk Exp $ +# $Id: privoxy-log-parser.pl,v 1.228 2010/02/13 15:25:10 fk Exp $ # # TODO: # - LOG_LEVEL_CGI, LOG_LEVEL_ERROR, LOG_LEVEL_WRITE content highlighting @@ -44,7 +44,7 @@ use warnings; use Getopt::Long; use constant { - PRIVOXY_LOG_PARSER_VERSION => '0.5', + PRIVOXY_LOG_PARSER_VERSION => '0.6', # Feel free to mess with these ... DEFAULT_BACKGROUND => 'black', # Choose registered colour (like 'black') DEFAULT_TEXT_COLOUR => 'white', # Choose registered colour (like 'black') @@ -56,7 +56,6 @@ use constant { CLI_OPTION_NO_EMBEDDED_CSS => 0, CLI_OPTION_NO_MSECS => 0, CLI_OPTION_NO_SYNTAX_HIGHLIGHTING => 0, - CLI_OPTION_ERROR_LOG_FILE => '/var/log/privoxy-log.log', CLI_OPTION_SHOW_INEFFECTIVE_FILTERS => 0, CLI_OPTION_ACCEPT_UNKNOWN_MESSAGES => 0, CLI_OPTION_STATISTICS => 0, @@ -80,6 +79,7 @@ use constant { PUNISH_MISSING_HIGHLIGHT_KNOWLEDGE_WITH_DEATH => 1, LOG_UNPARSED_LINES_TO_EXTRA_FILE => 0, + ERROR_LOG_FILE => '/var/log/privoxy-log-parser', # You better leave these alone unless you know what you're doing. COLOUR_RESET => "\033[0;0m", @@ -190,7 +190,7 @@ sub prepare_our_stuff () { 'Unsupported HTTP feature' => 'light_red', Blocked => 'light_red', Untrusted => 'light_red', - Redirected => 'green', + Redirected => 'green', 'CGI Call' => 'white', 'DNS failure' => 'red', 'Forwarding failed' => 'light_red', @@ -224,13 +224,13 @@ sub paint_it ($) { return "" if cli_option_is_set('no-syntax-highlighting'); my %light = ( - black => 0, - red => 0, - green => 0, - brown => 0, - blue => 0, - purple => 0, - cyan => 0, + black => 0, + red => 0, + green => 0, + brown => 0, + blue => 0, + purple => 0, + cyan => 0, light_gray => 0, gray => 0, dark_gray => 1, @@ -244,13 +244,13 @@ sub paint_it ($) { ); my %text = ( - black => 30, - red => 31, - green => 32, - brown => 33, - blue => 34, - purple => 35, - cyan => 36, + black => 30, + red => 31, + green => 32, + brown => 33, + blue => 34, + purple => 35, + cyan => 36, gray => 37, light_gray => 37, dark_gray => 30, @@ -273,9 +273,9 @@ sub paint_it ($) { $colour_code .= ";"; $colour_code .= $light{$colour} ? "1" : "2"; $colour_code .= ";"; - $colour_code .= $bg_code; + $colour_code .= $bg_code; $colour_code .= "m"; - debug_message $colour . " is \'" . $colour_code . $colour . $default . "\'" if DEBUG_PAINT_IT; + debug_message $colour . " is \'" . $colour_code . $colour . $default . "\'" if DEBUG_PAINT_IT; } elsif ($colour =~ /reset/) { @@ -283,7 +283,7 @@ sub paint_it ($) { } else { - die "What's $colour supposed to mean?\n"; + die "What's $colour supposed to mean?\n"; } return $colour_code; @@ -327,13 +327,13 @@ sub get_html_title () { sub init_css_colours() { our %css_colours = ( - black => "000", - red => "F00", - green => "0F0", - brown => "C90", - blue => "0F0", - purple => "F06", # XXX: wrong - cyan => "F09", # XXX: wrong + black => "000", + red => "F00", + green => "0F0", + brown => "C90", + blue => "0F0", + purple => "F06", # XXX: wrong + cyan => "F09", # XXX: wrong light_gray => "999", gray => "333", dark_gray => "222", @@ -352,7 +352,7 @@ sub get_css_colour ($) { our %css_colours; my $colour = shift; - die "What's $colour supposed to mean?\n" unless defined($css_colours{$colour}); + die "What's $colour supposed to mean?\n" unless defined($css_colours{$colour}); return '#' . $css_colours{$colour}; } @@ -363,10 +363,10 @@ sub get_css_line ($) { my $css_line; $css_line .= '.' . lc($class) . ' {'; # XXX: lc() shouldn't be necessary - die "What's $class supposed to mean?\n" unless defined($h_colours{$class}); + die "What's $class supposed to mean?\n" unless defined($h_colours{$class}); $css_line .= 'color:' . get_css_colour($h_colours{$class}) . ';'; $css_line .= 'background-color:' . get_css_colour(DEFAULT_BACKGROUND) . ';'; - $css_line .= '}' . "\n"; + $css_line .= '}' . "\n"; return $css_line; } @@ -379,7 +379,7 @@ sub get_css_line_for_colour ($) { $css_line .= '.' . lc($colour) . ' {'; # XXX: lc() shouldn't be necessary $css_line .= 'color:' . get_css_colour($colour) . ';'; $css_line .= 'background-color:' . get_css_colour(DEFAULT_BACKGROUND) . ';'; - $css_line .= '}' . "\n"; + $css_line .= '}' . "\n"; return $css_line; } @@ -392,7 +392,7 @@ sub get_missing_css_lines () { $css_line .= '.' . 'default' . ' {'; $css_line .= 'color:' . HEADER_DEFAULT_COLOUR . ';'; $css_line .= 'background-color:' . get_css_colour(DEFAULT_BACKGROUND) . ';'; - $css_line .= '}' . "\n"; + $css_line .= '}' . "\n"; return $css_line; } @@ -406,8 +406,8 @@ sub get_css () { $css .= '.privoxy-log {'; $css .= 'color:' . get_css_colour(DEFAULT_TEXT_COLOUR) . ';'; $css .= 'background-color:' . get_css_colour(DEFAULT_BACKGROUND) . ';'; - $css .= '}' . "\n"; - + $css .= '}' . "\n"; + foreach my $key (keys %h_colours) { next if ($h_colours{$key} =~ m/reset/); #XXX: Wrong solution. @@ -498,17 +498,17 @@ sub set_background ($){ my $colour = shift; our $bg_code; my %backgrounds = ( - black => "40", - red => "41", - green => "42", - brown => "43", - blue => "44", - magenta => "45", + black => "40", + red => "41", + green => "42", + brown => "43", + blue => "44", + magenta => "45", cyan => "46", - white => "47", - default => "49", + white => "47", + default => "49", ); - + if (defined($backgrounds{$colour})) { $bg_code = $backgrounds{$colour}; } else { @@ -527,7 +527,7 @@ sub prepare_highlight_hash ($) { $$ref{$key} = $html_output_mode ? get_semantic_html_markup($key) : paint_it($$ref{$key}); - } + } } sub prepare_colour_array ($) { @@ -577,7 +577,7 @@ sub debug_message (@) { } ################################################################################ -# highlighter functions that aren't loglevel-specific +# highlighter functions that aren't loglevel-specific ################################################################################ sub h ($) { @@ -598,7 +598,7 @@ sub h ($) { log_parser_error($message); die "Unworthy highlighter function" if PUNISH_MISSING_HIGHLIGHT_KNOWLEDGE_WITH_DEATH; } - + return $result; } @@ -780,30 +780,11 @@ sub update_header_highlight_regex ($) { sub handle_loglevel_header ($) { - my $content = shift; - my $c = $content; + my $c = shift; if ($c =~ /^scan:/) { - if ($c =~ m/^scan: ((\w+) (.+) (HTTP\/\d\.\d))/) { - - # Client request line - # Save for statistics (XXX: Not implemented yet) - $req{$t}{'method'} = $2; - $req{$t}{'destination'} = $3; - $req{$t}{'http-version'} = $4; - - $content = highlight_request_line($1); - - } elsif ($c =~ m/^(scan: )((?:HTTP\/\d\.\d|ICY) (\d+) (.*))/) { - - # Server response line - $req{$t}{'response_line'} = $2; - $req{$t}{'status_code'} = $3; - $req{$t}{'status_message'} = $4; - $content = $1 . highlight_response_line($req{$t}{'response_line'}); - - } elsif ($c =~ m/^scan: ((?>[^:]+)):/) { + if ($c =~ m/^scan: ([^: ]+):/) { # Register new headers # scan: Accept: image/png,image/*;q=0.8,*/*;q=0.5 @@ -820,48 +801,65 @@ sub handle_loglevel_header ($) { update_header_highlight_regex($header); } + } elsif ($c =~ m/^scan: ((\w+) (.+) (HTTP\/\d\.\d))/) { + + # Client request line + # Save for statistics (XXX: Not implemented yet) + $req{$t}{'method'} = $2; + $req{$t}{'destination'} = $3; + $req{$t}{'http-version'} = $4; + + $c = highlight_request_line($1); + + } elsif ($c =~ m/^(scan: )((?:HTTP\/\d\.\d|ICY) (\d+) (.*))/) { + + # Server response line + $req{$t}{'response_line'} = $2; + $req{$t}{'status_code'} = $3; + $req{$t}{'status_message'} = $4; + $c = $1 . highlight_response_line($req{$t}{'response_line'}); } } elsif ($c =~ m/^Crunching (?:server|client) header: .* \(contains: ([^\)]*)\)/) { # Crunching server header: Set-Cookie: trac_form_token=d5308c34e16d15e9e301a456; (contains: Cookie:) - $content =~ s@(?<=contains: )($1)@$h{'crunch-pattern'}$1$h{'Standard'}@; - $content =~ s@(Crunching)@$h{$1}$1$h{'Standard'}@; + $c =~ s@(?<=contains: )($1)@$h{'crunch-pattern'}$1$h{'Standard'}@; + $c =~ s@(Crunching)@$h{$1}$1$h{'Standard'}@; } elsif ($c =~ m/^New host is: ([^\s]*)\./) { - # New host is: trac.vidalia-project.net. Crunching Referer: http://www.vidalia-project.net/ - $c = highlight_matched_host($c, '(?<=New host is: )[^\s]+'); - $content = highlight_matched_url($c, '(?<=Crunching Referer: )[^\s]+'); + # New host is: trac.vidalia-project.net. Crunching Referer: http://www.vidalia-project.net/! + $c = highlight_matched_host($c, '(?<=New host is: )[^\s]+(?=\.)'); + $c = highlight_matched_url($c, '(?<=Crunching Referer: )[^\s!]+'); } elsif ($c =~ m/^Text mode enabled by force. (Take cover)!/) { # Text mode enabled by force. Take cover! - $content =~ s@($1)@$h{'warning'}$1$h{'Standard'}@; + $c =~ s@($1)@$h{'warning'}$1$h{'Standard'}@; } elsif ($c =~ m/^(New HTTP Request-Line: )(.*)/) { # New HTTP Request-Line: GET http://www.privoxy.org/ HTTP/1.1 - $content = $1 . highlight_request_line($2); + $c = $1 . highlight_request_line($2); } elsif ($c =~ m/^Adjust(ed)? Content-Length to \d+/) { # Adjusted Content-Length to 2132 # Adjust Content-Length to 33533 - $content =~ s@(?<=Content-Length to )(\d+)@$h{'Number'}$1$h{'Standard'}@; - $content = highlight_known_headers($content); + $c =~ s@(?<=Content-Length to )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $c = highlight_known_headers($c); } elsif ($c =~ m/^Destination extracted from "Host:" header. New request URL:/) { # Destination extracted from "Host:" header. New request URL: http://www.cccmz.de/~ridcully/blog/ - $content = highlight_matched_url($content, '(?<=New request URL: ).*'); + $c = highlight_matched_url($c, '(?<=New request URL: ).*'); } elsif ($c =~ m/^Couldn\'t parse:/) { # XXX: These should probable be logged with LOG_LEVEL_ERROR # Couldn't parse: If-Modified-Since: Wed, 21 Mar 2007 16:34:50 GMT (crunching!) # Couldn't parse: at, 24 Mar 2007 13:46:21 GMT in If-Modified-Since: Sat, 24 Mar 2007 13:46:21 GMT (crunching!) - $content =~ s@^(Couldn\'t parse)@$h{'error'}$1$h{'Standard'}@; + $c =~ s@^(Couldn\'t parse)@$h{'error'}$1$h{'Standard'}@; } elsif ($c =~ /^Tagger \'([^\']*)\' added tag \'([^\']*)\'/ or $c =~ m/^Adding tag \'([^\']*)\' created by header tagger \'([^\']*)\'/) { @@ -872,9 +870,9 @@ sub handle_loglevel_header ($) { # XXX: Save tag and tagger - $content =~ s@(?<=^Tagger \')([^\']*)@$h{'tagger'}$1$h{'Standard'}@; - $content =~ s@(?<=added tag \')([^\']*)@$h{'tag'}$1$h{'Standard'}@; - $content =~ s@(?<=Action bits )(updated)@$h{'action-bits-update'}$1$h{'Standard'}@; + $c =~ s@(?<=^Tagger \')([^\']*)@$h{'tagger'}$1$h{'Standard'}@; + $c =~ s@(?<=added tag \')([^\']*)@$h{'tag'}$1$h{'Standard'}@; + $c =~ s@(?<=Action bits )(updated)@$h{'action-bits-update'}$1$h{'Standard'}@; $no_special_header_highlighting = 1; } elsif ($c =~ /^Tagger \'([^\']*)\' didn['']t add tag \'([^\']*)\'/) { @@ -882,8 +880,8 @@ sub handle_loglevel_header ($) { # Tagger 'revalidation' didn't add tag 'REVALIDATION-REQUEST'. Tag already present # XXX: Save tag and tagger - $content =~ s@(?<=^Tagger \')([^\']*)@$h{'tag'}$1$h{'Standard'}@; - $content =~ s@(?<=didn['']t add tag \')([^\']*)@$h{'tagger'}$1$h{'Standard'}@; + $c =~ s@(?<=^Tagger \')([^\']*)@$h{'tag'}$1$h{'Standard'}@; + $c =~ s@(?<=didn['']t add tag \')([^\']*)@$h{'tagger'}$1$h{'Standard'}@; } elsif ($c =~ m/^(?:scan:|Randomiz|addh:|Adding:|Removing:|Referer:|Modified:|Accept-Language header|[Cc]ookie)/ or $c =~ m/^(Text mode is already enabled|Denied request with NULL byte|Replaced:|add-unique:)/ @@ -964,21 +962,21 @@ sub handle_loglevel_header ($) { # crunched User-Agent! # Crunching: Content-Encoding: gzip - $content =~ s@(Crunching|crunched)@$h{$1}$1$h{'Standard'}@; + $c =~ s@(Crunching|crunched)@$h{$1}$1$h{'Standard'}@; } elsif ($c =~ m/^Offending request data with NULL bytes turned into \'°\' characters:/) { - + # Offending request data with NULL bytes turned into '°' characters: °°n°°(°°° - $content = h('warning') . $content . h('Standard'); - + $c = h('warning') . $c . h('Standard'); + } elsif ($c =~ m/^(Transforming \")(.*?)(\" to \")(.*?)(\")/) { # Transforming "Proxy-Authenticate: Basic realm="Correos Proxy Server"" to\ # "Proxy-Authenticate: Basic realm="Correos Proxy Server"" - $content =~ s@(?<=^Transforming \")(.*)(?=\" to)@$h{'Header'}$1$h{'Standard'}@; - $content =~ s@(?<=to \")(.*)(?=\")@$h{'Header'}$1$h{'Standard'}@; + $c =~ s@(?<=^Transforming \")(.*)(?=\" to)@$h{'Header'}$1$h{'Standard'}@; + $c =~ s@(?<=to \")(.*)(?=\")@$h{'Header'}$1$h{'Standard'}@; } elsif ($c =~ m/^Removing empty header/) { @@ -990,34 +988,34 @@ sub handle_loglevel_header ($) { # Content-Type: application/octet-stream not replaced. It doesn't look like text.\ # Enable force-text-mode if you know what you're doing. # XXX: Could highlight more here. - $content =~ s@(?<=^Content-Type: )(.*)(?= not replaced)@$h{'content-type'}$1$h{'Standard'}@; + $c =~ s@(?<=^Content-Type: )(.*)(?= not replaced)@$h{'content-type'}$1$h{'Standard'}@; } elsif ($c =~ m/^(Server|Client) keep-alive timeout is/) { # Server keep-alive timeout is 5. Sticking with 10. # Client keep-alive timeout is 20. Sticking with 10. - $content =~ s@(?<=timeout is )(\d+)@$h{'Number'}$1$h{'Standard'}@; - $content =~ s@(?<=Sticking with )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $c =~ s@(?<=timeout is )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $c =~ s@(?<=Sticking with )(\d+)@$h{'Number'}$1$h{'Standard'}@; } elsif ($c =~ m/^Reducing keep-alive timeout/) { # Reducing keep-alive timeout from 60 to 10. - $content =~ s@(?<= from )(\d+)@$h{'Number'}$1$h{'Standard'}@; - $content =~ s@(?<= to )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $c =~ s@(?<= from )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $c =~ s@(?<= to )(\d+)@$h{'Number'}$1$h{'Standard'}@; } else { - found_unknown_content($content); + found_unknown_content($c); } - # Highlight headers + # Highlight headers unless ($c =~ m/^Transforming/) { - $content = highlight_known_headers($content) unless $no_special_header_highlighting; + $c = highlight_known_headers($c) unless $no_special_header_highlighting; } - return $content; + return $c; } sub handle_loglevel_re_filter ($) { @@ -1073,7 +1071,7 @@ sub handle_loglevel_re_filter ($) { $req{$t}{'header_filter_name'} =~ m/^privoxy-filter-test$/) { return ''; } - $content =~ s@(?<=\(size )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $content =~ s@(?<=\(size )(\d+)@$h{'Number'}$1$h{'Standard'}@; $content =~ s@($req{$t}{'header_filter_name'})@$h{'filter'}$1$h{'Standard'}@; } elsif ($c =~ m/^ ?\.\.\. ?produced (\d*) hits \(new size (\d*)\)\./) { @@ -1091,7 +1089,7 @@ sub handle_loglevel_re_filter ($) { if ($req{$t}{'header_filter_hits'} == 0 and not (defined($req{$t}{'header_filter_name'}) and $req{$t}{'header_filter_name'} =~ m/^privoxy-filter-test$/)) { - return ''; + return ''; } # Reformat including information from the intro $c = "'" . h('filter') . $req{$t}{'header_filter_name'} . h('Standard') . "'"; @@ -1116,7 +1114,7 @@ sub handle_loglevel_re_filter ($) { } # Highlight from last line (XXX: What?) - # $c =~ s@(?<=produced )(\d+)@$h{'Number'}$1$h{'Standard'}@; + # $c =~ s@(?<=produced )(\d+)@$h{'Number'}$1$h{'Standard'}@; # $c =~ s@($req{$t}{'header_filter_name'})@$h{'filter'}$1$h{'Standard'}@; } else { @@ -1278,7 +1276,7 @@ sub handle_loglevel_gif_deanimate ($) { } elsif ($content =~ m/^failed! \(gif parsing\)/) { # failed! (gif parsing) - # XXX: Replace this error message with something less stupid + # XXX: Replace this error message with something less stupid $content =~ s@(failed!)@$h{'error'}$1$h{'Standard'}@; } elsif ($content =~ m/^Need to de-chunk first/) { @@ -1333,7 +1331,7 @@ sub handle_loglevel_request ($) { found_unknown_content($content); } - + return $content; } @@ -1445,7 +1443,7 @@ sub handle_loglevel_connect ($) { $c = highlight_matched_host($c, '(?<=from )[^\s]+'); # XXX: not an URL } elsif ($c =~ m/^socks5_connect:/) { - + $c =~ s@(?<=socks5_connect: )(.*)@$h{'error'}$1$h{'Standard'}@; } elsif ($c =~ m/^Created new connection to/) { @@ -1657,7 +1655,7 @@ sub handle_loglevel_connect ($) { found_unknown_content($c); } - + return $c; } @@ -1665,7 +1663,7 @@ sub handle_loglevel_connect ($) { sub handle_loglevel_info ($) { my $c = shift; - + if ($c =~ m/^Rewrite detected:/) { # Rewrite detected: GET http://10.0.0.2:88/blah.txt HTTP/1.1 @@ -1690,12 +1688,12 @@ sub handle_loglevel_info ($) { $c =~ s@(?<=loading configuration file \')([^\']*)@$h{'file'}$1$h{'Standard'}@; } elsif ($c =~ m/^exiting by signal/) { - + # exiting by signal 15 .. bye $c =~ s@(?<=exiting by signal )(\d+)@$h{'signal'}$1$h{'Standard'}@; } elsif ($c =~ m/^Privoxy version/) { - + # Privoxy version 3.0.7 $c =~ s@(?<=^Privoxy version )(\d+\.\d+\.\d+)$@$h{'version'}$1$h{'Standard'}@; @@ -1746,7 +1744,8 @@ sub handle_loglevel_info ($) { $c =~ m/^Malformerd HTTP headers detected and MS IIS5 hack enabled/ or $c =~ m/^Invalid \"chunked\" transfer/ or $c =~ m/^Support for/ or - $c =~ m/^Flushing header and buffers/ + $c =~ m/^Flushing header and buffers/ or + $c =~ m/^Can not resolve/ ) { # No logfile configured. Please enable it before reporting any problems. @@ -1757,6 +1756,7 @@ sub handle_loglevel_info ($) { # Support for 'Connection: keep-alive' is experimental, incomplete and\ # known not to work properly in some situations. # Flushing header and buffers. Stepping back from filtering. + # Can not resolve doesnotexist: hostname nor servname provided, or not known } else { @@ -1772,11 +1772,11 @@ sub handle_loglevel_cgi ($) { my $c = shift; if ($c =~ m/^Granting access to/) { - + #Granting access to http://config.privoxy.org/send-stylesheet, referrer http://p.p/ is trustworthy. } elsif ($c =~ m/^Substituting: s(.)/) { - + # Substituting: s/@else-not-FEATURE_ZLIB@.*@endif-FEATURE_ZLIB@//sigTU # XXX: prone to span several lines @@ -1794,13 +1794,13 @@ sub handle_loglevel_force ($) { my $c = shift; if ($c =~ m/^Ignored force prefix in request:/) { - + # Ignored force prefix in request: "GET http://10.0.0.1/PRIVOXY-FORCE/block HTTP/1.1" $c =~ s@^(Ignored)@$h{'ignored'}$1$h{'Standard'}@; $c = highlight_matched_request_line($c, '(?<=request: ")[^"]*'); } elsif ($c =~ m/^Enforcing request:/) { - + # Enforcing request: "GET http://10.0.0.1/block HTTP/1.1". $c = highlight_matched_request_line($c, '(?<=request: ")[^"]*'); @@ -1874,8 +1874,7 @@ sub gather_loglevel_error_stats ($$) { sub gather_loglevel_connect_stats ($$) { - my $c = shift; - my $thread = shift; + my ($c, $thread) = @_; our %thread_data; our %stats; @@ -1907,10 +1906,9 @@ sub gather_loglevel_connect_stats ($$) { } } -sub gather_loglevel_header_stats ($) { +sub gather_loglevel_header_stats ($$) { - my $c = shift; - my $thread = shift; + my ($c, $thread) = @_; our %stats; if ($c =~ m/^A HTTP\/1\.1 response without/ or @@ -2056,7 +2054,7 @@ sub parse_loop () { ); while (<>) { - + if (m/^(\w{3} \d{2}) (\d\d:\d\d:\d\d)\.?(\d+)? (?:Privoxy\()?([^\)\s]*)[\)]? ([\w -]*): (.*?)\r?$/) { $thread = $t = $4; $req{$t}{'day'} = $day = $1; @@ -2074,12 +2072,11 @@ sub parse_loop () { } else { die "No handler found for log level \"$log_level\"\n"; - } - # Highlight Truncations - if (m/\.\.\. \[(too long, truncated)/) { - $content =~ s@($1)@$h{'Truncation'}$1$h{'Standard'}@g; + # Highlight Truncations + if (length($_) > 4000) { + $content =~ s@(too long, truncated)]$@$h{'Truncation'}$1$h{'Standard'}]@g; } next unless $content; @@ -2093,7 +2090,7 @@ sub parse_loop () { # Switch timestamp colour if timestamps differ if (($msecs ne $last_msecs) || ($time_stamp ne $last_timestamp)) { debug_message("Tick tack!") if DEBUG_TICKS; - $time_colour = $time_colours[$time_colour_index % 2]; + $time_colour = $time_colours[$time_colour_index % 2]; $time_colour_index++; $last_msecs = $msecs; $last_timestamp = $time_stamp; @@ -2112,7 +2109,7 @@ sub parse_loop () { our ($ip, $timestamp, $request_line, $status_code, $size) = ($1, $2, $3, $4, $5); print_clf_message(); - + } else { # Some Privoxy log messages span more than one line, @@ -2128,7 +2125,7 @@ sub parse_loop () { sub stats_loop () { - my ($day, $time_stamp, $thread, $log_level, $content, $c, $msecs); + my ($day, $time_stamp, $msecs, $thread, $log_level, $content); my %log_level_handlers = ( 'Re-Filter' => \&handle_loglevel_ignore, 'Header' => \&gather_loglevel_header_stats, @@ -2151,9 +2148,9 @@ sub stats_loop () { $day = $1; $time_stamp = $2; $msecs = $3 ? $3 : 0; - $log_level = $5; - $content = $c = $6; $thread = $4; + $log_level = $5; + $content = $6; if (defined($log_level_handlers{$log_level})) { @@ -2192,7 +2189,7 @@ sub get_cli_options () { 'show-ineffective-filters' => CLI_OPTION_SHOW_INEFFECTIVE_FILTERS, 'accept-unknown-messages' => CLI_OPTION_ACCEPT_UNKNOWN_MESSAGES, 'statistics' => CLI_OPTION_STATISTICS, - ); + ); GetOptions ( 'html-output' => \$cli_options{'html-output'}, @@ -2281,7 +2278,7 @@ B reads Privoxy log messages and - (in some cases) calculates additional information, like the compression ratio or how a filter affected the content size. - + With B you should be able to increase Privoxy's log level without getting confused by the resulting amount of output. For example for "debug 64" B will (by default) only show messages that @@ -2310,7 +2307,7 @@ that didn't modify the content. [B<--statistics>] Gather various statistics instead of syntax highlighting log messages. This is an experimental feature, if the results look wrong -they very well might be. Also note that the results a pretty much guaranteed +they very well might be. Also note that the results are pretty much guaranteed to be incorrect if Privoxy and Privoxy-Log-Parser aren't in sync. [B<--version>] Print version and exit.