checkLogs.pl 1.2 KB

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