Highlight:
[privoxy.git] / tools / privoxy-log-parser.pl
index f1a776b..c2b76a7 100755 (executable)
@@ -8,7 +8,7 @@
 #
 # http://www.fabiankeil.de/sourcecode/privoxy-log-parser/
 #
-# $Id: privoxy-log-parser.pl,v 1.118 2008/11/01 14:10:53 fk Exp $
+# $Id: privoxy-log-parser.pl,v 1.127 2008/12/06 11:29:58 fk Exp $
 #
 # TODO:
 #       - LOG_LEVEL_CGI, LOG_LEVEL_ERROR, LOG_LEVEL_WRITE content highlighting
@@ -914,6 +914,8 @@ sub handle_loglevel_header ($) {
           or $c =~ m/^Reducing white space in /
           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
@@ -950,6 +952,8 @@ sub handle_loglevel_header ($) {
         # Ignoring single quote in 'X-LWS-Test: "This  is  quoted" this is not "this  is  " but "  this again   is  not'
         # 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:/) {
 
@@ -1419,6 +1423,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.
@@ -1448,17 +1458,16 @@ sub handle_loglevel_connect ($) {
 
     } elsif ($c =~ m/^Socket/) {
 
-        # Socket 18 for www.privoxy.org:80 in slot 0 is no longer usable. Closing.
         # Socket 16 already forgotten or never remembered.
         $c =~ s@(?<=Socket )(\d+)@$h{'Number'}$1$h{'Standard'}@;
-        $c = highlight_matched_host($c, '(?<=for )[^\s]+');
-        $c =~ s@(?<=in slot )(\d+)@$h{'Number'}$1$h{'Standard'}@;
 
     } elsif ($c =~ m/^The connection to/) {
 
-        # The connection to www.privoxy.org:80 in slot 0 timed out. Closing.
+        # The connection to www.privoxy.org:80 in slot 6 timed out. Closing socket 19.
+        # The connection to 10.0.0.1:80 in slot 0 is no longer usable. Closing socket 4.
         $c = highlight_matched_host($c, '(?<=connection to )[^\s]+');
         $c =~ s@(?<=in slot )(\d+)@$h{'Number'}$1$h{'Standard'}@;
+        $c =~ s@(?<=Closing socket )(\d+)@$h{'Number'}$1$h{'Standard'}@;
 
     } elsif ($c =~ m/^Initialized/) {
 
@@ -1473,9 +1482,20 @@ 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/) {
+    } 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/^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 {
 
@@ -1748,7 +1768,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;