projects
/
privoxy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
874ab06
)
privoxy-log-parser: Detect date changes when looking for inactivity
author
Fabian Keil
<fk@fabiankeil.de>
Wed, 24 Mar 2021 06:55:54 +0000
(07:55 +0100)
committer
Fabian Keil
<fk@fabiankeil.de>
Wed, 1 Dec 2021 16:03:41 +0000
(17:03 +0100)
tools/privoxy-log-parser.pl
patch
|
blob
|
history
diff --git
a/tools/privoxy-log-parser.pl
b/tools/privoxy-log-parser.pl
index
1a8b8db
..
00fc2bd
100755
(executable)
--- a/
tools/privoxy-log-parser.pl
+++ b/
tools/privoxy-log-parser.pl
@@
-2760,24
+2760,27
@@
sub time_stamp_to_msecs($) {
sub inactivity_detection_loop() {
our %cli_options;
sub inactivity_detection_loop() {
our %cli_options;
- my ($time_stamp, $thread, $log_level, $content);
+ my ($
date, $
time_stamp, $thread, $log_level, $content);
my ($msecs, $previous_msecs, $inactivity);
my $inactivity_threshold = $cli_options{'inactivity-threshold'};
my ($msecs, $previous_msecs, $inactivity);
my $inactivity_threshold = $cli_options{'inactivity-threshold'};
- my $previous_
messag
e;
- my $log_message_out_of_order = 0;
+ my $previous_
dat
e;
+ my $log_message
s
_out_of_order = 0;
while (<>) {
while (<>) {
- (
undef
, $time_stamp, $thread, $log_level, $content) = split(/ /, $_, 5);
+ (
$date
, $time_stamp, $thread, $log_level, $content) = split(/ /, $_, 5);
next if (not defined($log_level));
next if ($time_stamp eq "-");
$msecs = time_stamp_to_msecs($time_stamp);
unless (defined $msecs) {
print "Failed to convert $time_stamp into miliseconds\n";
next if (not defined($log_level));
next if ($time_stamp eq "-");
$msecs = time_stamp_to_msecs($time_stamp);
unless (defined $msecs) {
print "Failed to convert $time_stamp into miliseconds\n";
+ print "$_";
next;
}
unless (defined $previous_msecs) {
$previous_msecs = $msecs;
next;
}
unless (defined $previous_msecs) {
$previous_msecs = $msecs;
+ $previous_date = $date;
+ print "$_";
next;
}
$inactivity = $msecs - $previous_msecs;
next;
}
$inactivity = $msecs - $previous_msecs;
@@
-2786,18
+2789,23
@@
sub inactivity_detection_loop() {
# a Privoxy thread may be moved off schedule between
# getting the timestamp for the log message and actually
# writing it.
# a Privoxy thread may be moved off schedule between
# getting the timestamp for the log message and actually
# writing it.
- $log_message_out_of_order++;
+ $log_message
s
_out_of_order++;
}
if ($inactivity > $inactivity_threshold) {
}
if ($inactivity > $inactivity_threshold) {
- #print "$previous_message";
- print "Detected inactivity: $inactivity msecs\n";
+ if ($previous_date eq $date) {
+ print "Detected inactivity: $inactivity msecs\n";
+ } else {
+ # While we could include the date in the timestamp
+ # we currently don't.
+ print "Detected date change. Timestamp difference ignored.\n";
+ }
}
print "$_";
$previous_msecs = $msecs;
}
print "$_";
$previous_msecs = $msecs;
- $previous_
message = $_
;
+ $previous_
date = $date
;
}
}
- if ($log_message_out_of_order) {
- print "At least $log_message_out_of_order messages were written out of the chronological order.\n";
+ if ($log_message
s
_out_of_order) {
+ print "At least $log_message
s
_out_of_order messages were written out of the chronological order.\n";
print "This can result in false positives. Consider sorting the log first.\n";
}
}
print "This can result in false positives. Consider sorting the log first.\n";
}
}