tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

checkLogs.pl (1180B)


      1 #!/usr/bin/perl -w
      2 
      3 use strict;
      4 
      5 my %count = ();
      6 my $more = 0;
      7 my $last = "";
      8 
      9 while (<>) {
     10    if ($more) {
     11        if (/LD_BUG/) {
     12            $more = 0;
     13            next;
     14        }
     15        if (/\"((?:[^\"\\]+|\\.*)+)\"(.*)/) {
     16            $last .= $1;
     17            if ($2 !~ /[,\)]/) {
     18                $more = 1;
     19            } else {
     20                $count{lc $last}++;
     21                $more = 0;
     22            }
     23        } elsif (/[,\)]/) {
     24            $count{lc $last}++;
     25            $more = 0;
     26        } elsif ($more == 2) {
     27            print "SKIPPED more\n";
     28        }
     29    } elsif (/log_(?:warn|err|notice)\(\s*(LD_[A-Z_]*)\s*,\s*\"((?:[^\"\\]+|\\.)*)\"(.*)/) {
     30        next if ($1 eq 'LD_BUG');
     31        my $s = $2;
     32        if ($3 =~ /[,\)]/ ) {
     33            $count{lc $s}++;
     34        } else {
     35            $more = 1;
     36            $last = $s;
     37        }
     38    } elsif (/log_(?:warn|err|notice)\(\s*((?:LD_[A-Z_]*)?)(.*)/) {
     39        next if ($1 eq 'LD_BUG');
     40        my $extra = $2;
     41        chomp $extra;
     42        $last = "";
     43        $more = 2 if ($extra eq '');
     44    }
     45 }
     46 
     47 while ((my $phrase, my $count) = each %count) {
     48    if ($count > 1) {
     49        print "$count\t$phrase\n";
     50    }
     51 }