[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8539: Add a perl script and a make target to find and check for du (in tor/trunk: . contrib)



Author: nickm
Date: 2006-09-29 18:33:28 -0400 (Fri, 29 Sep 2006)
New Revision: 8539

Added:
   tor/trunk/contrib/checkLogs.pl
Modified:
   tor/trunk/
   tor/trunk/Makefile.am
Log:
 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.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r9021] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/Makefile.am
===================================================================
--- tor/trunk/Makefile.am	2006-09-29 22:19:56 UTC (rev 8538)
+++ tor/trunk/Makefile.am	2006-09-29 22:33:28 UTC (rev 8539)
@@ -63,3 +63,6 @@
 		src/common/[^as]*.c                   \
 		src/or/[^et]*.[ch] src/or/t*.c src/or/eventdns_tor.h
 
+check-logs:
+	./contrib/checkLogs.pl                        \
+		src/*/*.[ch] | sort -n

Added: tor/trunk/contrib/checkLogs.pl
===================================================================
--- tor/trunk/contrib/checkLogs.pl	2006-09-29 22:19:56 UTC (rev 8538)
+++ tor/trunk/contrib/checkLogs.pl	2006-09-29 22:33:28 UTC (rev 8539)
@@ -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";
+    }
+}