diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-09-29 22:33:28 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-09-29 22:33:28 +0000 |
commit | 174c3dc6b7d571e33b384a976e23c838cf2bfa80 (patch) | |
tree | f98adaa7fa63d11c8e336318d0079e0bfa517c8a /contrib/checkLogs.pl | |
parent | 8058a608381ffc77de211d0936f8883809238b64 (diff) | |
download | tor-174c3dc6b7d571e33b384a976e23c838cf2bfa80.tar.gz tor-174c3dc6b7d571e33b384a976e23c838cf2bfa80.zip |
r9021@Kushana: nickm | 2006-09-29 16:58:41 -0400
Add a perl script and a make target to find and check for duplicate log messages at level notice or higher.
svn:r8539
Diffstat (limited to 'contrib/checkLogs.pl')
-rw-r--r-- | contrib/checkLogs.pl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/contrib/checkLogs.pl b/contrib/checkLogs.pl new file mode 100644 index 0000000000..9a5e287f52 --- /dev/null +++ b/contrib/checkLogs.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl -w + +use strict; + +my %count = (); +my $more = 0; +my $last = ""; + +while (<>) { + if ($more) { + if (/\s*(?:LD_[A-Z]*,)?\"((?:[^\"\\]+|\\.*)+)\"(.*)/) { + $last .= $1; + if ($2 !~ /[,\)]/) { + $more = 1; + } else { + $count{$last}++; + $more = 0; + } + } elsif (/[,\)]/) { + $count{$last}++; + $more = 0; + } elsif ($more == 2) { + print "SKIPPED more\n"; + } + } elsif (/log_(?:warn|err|notice)\([^\"]*\"((?:[^\"\\]+|\\.)*)\"(.*)/) { + my $s = $1; + if ($2 =~ /[,\)]/ ) { + $count{$s}++; + } else { + $more = 1; + $last = $s; + } + } elsif (/log_(?:warn|err|notice)\((?:LD_[A-Z]*,)?(.*)/) { + my $extra = $1; + chomp $extra; + $last = ""; + $more = 2 if ($extra eq ''); + } +} + +while ((my $phrase, my $count) = each %count) { + if ($count > 1) { + print "$count\t$phrase\n"; + } +} |