#
# http://www.fabiankeil.de/sourcecode/privoxy-log-parser/
#
-# $Id: privoxy-log-parser.pl,v 1.160 2009/07/21 09:46:59 fk Exp fk $
+# $Id: privoxy-log-parser.pl,v 1.167 2009/08/20 15:42:57 fk Exp $
#
# TODO:
# - LOG_LEVEL_CGI, LOG_LEVEL_ERROR, LOG_LEVEL_WRITE content highlighting
$c =~ s@(?<=server socket )(\d+)@$h{'Number'}$1$h{'Standard'}@;
+ } elsif ($c =~ m/^Reduced expected bytes to /) {
+
+ # Reduced expected bytes to 0 to account for the 1542 ones we already got.
+ $c =~ s@(?<=bytes to )(\d+)@$h{'Number'}$1$h{'Standard'}@;
+ $c =~ s@(?<=for the )(\d+)@$h{'Number'}$1$h{'Standard'}@;
+
} elsif ($c =~ m/^Looks like we rea/ or
$c =~ m/^Unsetting keep-alive flag/ or
$c =~ m/^No connections to wait/ or
$c =~ m/^Possible pipeline attempt detected./ or
$c =~ m/^POST request detected. The connection will not be kept alive./ or
$c =~ m/^The server still wants to talk, but the client hung up on us./ or
- $c =~ m/^The server didn't specify how long the connection will stay open/) {
+ $c =~ m/^The server didn't specify how long the connection will stay open/ or
+ $c =~ m/^There might be a request body. The connection will not be kept alive/) {
# 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 \
# POST request detected. The connection will not be kept alive.
# The server still wants to talk, but the client hung up on us.
# The server didn't specify how long the connection will stay open. Assume it's only a second.
+ # There might be a request body. The connection will not be kept alive.
} else {
return $c;
}
+sub handle_loglevel_error ($) {
+
+ my $c = shift;
+ our %h;
+
+ if ($c =~ m/^Empty server or forwarder response received on socket \d+./) {
+
+ # Empty server or forwarder response received on socket 4.
+ $c =~ s@(?<=on socket )(\d+)@$h{'Number'}$1$h{'Standard'}@;
+ }
+ # XXX: There are probably more messages that deserve highlighting.
+
+ return $c;
+}
+
+
sub handle_loglevel_ignore ($) {
return shift;
}
'Info' => \&handle_loglevel_info,
'CGI' => \&handle_loglevel_cgi,
'Force' => \&handle_loglevel_force,
- 'Error' => \&handle_loglevel_ignore,
+ 'Error' => \&handle_loglevel_error,
'Fatal error' => \&handle_loglevel_ignore,
'Writing' => \&handle_loglevel_ignore,
'Unknown log level' => \&handle_loglevel_ignore,
$output = '';
- if (m/^(\w{3} \d{2}) (\d\d:\d\d:\d\d)\.?(\d+)? (?:Privoxy\()?([^\)\s]*)[\)]? ([\w -]*): (.*)$/) {
+ if (m/^(\w{3} \d{2}) (\d\d:\d\d:\d\d)\.?(\d+)? (?:Privoxy\()?([^\)\s]*)[\)]? ([\w -]*): (.*?)\r?$/) {
# XXX: Put in req hash?
$day = $1;
$time_stamp = $2;