summaryrefslogtreecommitdiff
path: root/contrib/checkLogs.pl
blob: 9a5e287f529c7d2f2fb75cafde4aa6c4b8a19cdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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";
    }
}