X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=tools%2Fprivoxy-log-parser.pl;h=7793acf54dfcce0553353a1b594f3e3350e5bc96;hb=eff85289dc4939901925b1c87304a7a537e8b477;hp=22be23968369d5de31f23b2abe5f308bf93a6643;hpb=c4c6ba0072177143b28ce73b62ac11256026ab11;p=privoxy.git diff --git a/tools/privoxy-log-parser.pl b/tools/privoxy-log-parser.pl index 22be2396..7793acf5 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.122 2008/11/08 15:34:01 fk Exp $ +# $Id: privoxy-log-parser.pl,v 1.129 2008/12/14 16:24:53 fk Exp $ # # TODO: # - LOG_LEVEL_CGI, LOG_LEVEL_ERROR, LOG_LEVEL_WRITE content highlighting @@ -106,6 +106,7 @@ sub prepare_our_stuff () { CGI => 'light_green', Redirect => 'cyan', Error => 'light_red', + Crunch => 'cyan', 'Fatal error' => 'light_red', 'Gif-Deanimate' => 'blue', Force => 'red', @@ -265,7 +266,6 @@ sub paint_it ($) { return $colour_code; } - sub get_semantic_html_markup ($) { ############################################################### # Takes a string and returns a span element @@ -438,7 +438,6 @@ sub print_outro () { } } - sub get_line_end () { my $line_end = "\n"; @@ -467,7 +466,6 @@ sub get_colour_html_markup ($) { return $code; } - sub default_colours () { # XXX: Properly our $bg_code; @@ -752,7 +750,6 @@ sub highlight_matched_pattern ($$$) { return $result; } - sub highlight_matched_path ($$) { my $result = shift; # XXX: Stupid name; @@ -765,7 +762,6 @@ sub highlight_matched_path ($$) { return $result; } - sub highlight_url ($) { my $url = shift; @@ -915,6 +911,7 @@ sub handle_loglevel_header ($) { or $c =~ m/^Ignoring single quote in / or $c =~ m/^Converting tab to space in / or $c =~ m/A HTTP\/1\.1 response without/ + or $c =~ m/Disabled filter mode on behalf of the client/ ) { # XXX: Some of these may need highlighting @@ -952,6 +949,7 @@ sub handle_loglevel_header ($) { # Converting tab to space in 'X-LWS-Test: "This is quoted" this is not "this is " but "\ # this again is not' # A HTTP/1.1 response without Connection header implies keep-alive. + # Disabled filter mode on behalf of the client. } elsif ($c =~ m/^scanning headers for:/) { @@ -1183,7 +1181,6 @@ sub handle_loglevel_re_filter ($) { return $content; } - sub handle_loglevel_redirect ($) { my $c = shift; @@ -1292,7 +1289,6 @@ sub handle_loglevel_gif_deanimate ($) { return $content; } - sub handle_loglevel_request ($) { my $content = shift; @@ -1332,6 +1328,32 @@ sub handle_loglevel_request ($) { return $content; } +sub handle_loglevel_crunch ($) { + + my $content = shift; + our %h; + our %reason_colours; + + # Blocked: ads.example.org/ + + # Highlight crunch reason + foreach my $reason (keys %reason_colours) { + $content =~ s@($reason)@$reason_colours{$reason}$1$h{'Standard'}@g; + } + # Highlight request URL + $content = highlight_matched_pattern($content, 'request_', '(?<= )[^ \[]*$'); + + if ($content =~ m/\[too long, truncated\]$/) { + + # Blocked: config.privoxy.org/edit-actions-submit?f=3&v=1176116716&s=7&Submit=Submit\ + # [...]&filter... [too long, truncated] + $content = highlight_matched_pattern($content, 'request_', '^.*(?=\.\.\. \[too long, truncated\]$)'); + + } + + return $content; +} + sub handle_loglevel_connect ($) { my $c = shift; @@ -1421,6 +1443,12 @@ sub handle_loglevel_connect ($) { $c =~ s@(?<=socks5_connect: )(.*)@$h{'error'}$1$h{'Standard'}@; + } elsif ($c =~ m/^Created new connection to/) { + + # Created new connection to www.privoxy.org:80 on socket 11. + $c = highlight_matched_host($c, '(?<=connection to )[^\s]+'); + $c =~ s@(?<=on socket )(\d+)@$h{'Number'}$1$h{'Standard'}@; + } elsif ($c =~ m/^Found reusable socket/) { # Found reusable socket 9 for www.privoxy.org:80 in slot 0. @@ -1474,10 +1502,25 @@ sub handle_loglevel_connect ($) { $c =~ s@(?<=Actual content length: )(\d+)@$h{'Number'}$1$h{'Standard'}@; $c =~ s@(?<=received: )(\d+)@$h{'Number'}$1$h{'Standard'}@; - } elsif ($c =~ m/^Looks like we reached/ or + } elsif ($c =~ m/^Continuing buffering headers/) { + + # Continuing buffering headers. byte_count: 19. header_offset: 517. len: 536. + $c =~ s@(?<=byte_count: )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $c =~ s@(?<=header_offset: )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $c =~ s@(?<=len: )(\d+)@$h{'Number'}$1$h{'Standard'}@; + + } elsif ($c =~ m/^Received \d+ bytes while/) { + + # Received 206 bytes while expecting 12103. + $c =~ s@(?<=Received )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $c =~ s@(?<=expecting )(\d+)@$h{'Number'}$1$h{'Standard'}@; + + } elsif ($c =~ m/^Looks like we rea/ or $c =~ m/^Unsetting keep-alive flag/) { # Looks like we reached the end of the last chunk. We better stop reading. + # Looks like we read the end of the last chunk together with the server \ + # headers. We better stop reading. # Unsetting keep-alive flag. } else { @@ -1738,6 +1781,7 @@ sub parse_loop () { 'Connect' => \&handle_loglevel_connect, 'Redirect' => \&handle_loglevel_redirect, 'Request' => \&handle_loglevel_request, + 'Crunch' => \&handle_loglevel_crunch, 'Gif-Deanimate' => \&handle_loglevel_gif_deanimate, 'Info' => \&handle_loglevel_info, 'CGI' => \&handle_loglevel_cgi, @@ -1751,7 +1795,7 @@ sub parse_loop () { $output = ''; - if (m/^(\w{3} \d{2}) (\d\d:\d\d:\d\d)\.?(\d+)? (?:Privoxy\(([^\)]*)\)) ([\w -]*): (.*)$/) { + if (m/^(\w{3} \d{2}) (\d\d:\d\d:\d\d)\.?(\d+)? (?:Privoxy\()?([^\)\s]*)[\)]? ([\w -]*): (.*)$/) { # XXX: Put in req hash? $day = $1; $time_stamp = $2;