#
# http://www.fabiankeil.de/sourcecode/privoxy-log-parser/
#
-# $Id: privoxy-log-parser.pl,v 1.69 2009/12/31 11:54:55 fabiankeil 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
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')
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,
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",
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;
-
- $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/^scan: ((?>[^:]+)):/) {
+ if ($c =~ m/^scan: ([^: ]+):/) {
# Register new headers
# scan: Accept: image/png,image/*;q=0.8,*/*;q=0.5
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: ([^\)]*)\)/) {
} 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]+');
- $c = 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)!/) {
$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.
# 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 {
sub gather_loglevel_connect_stats ($$) {
- my $c = shift;
- my $thread = shift;
+ my ($c, $thread) = @_;
our %thread_data;
our %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
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,
$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})) {
[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.