3 # Program to do a grep with dates and times on the debug
6 # dispdbg [-nnn ...] <string>
8 # the -nnn is the day you what to look at -1 is yesterday -0 is today
9 # and is optional if there is only one argument
10 # <string> is the string, a caseless search is done
16 # search local then perl directories
18 # root of directory tree for this system
20 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
22 unshift @INC, "$root/perl"; # this IS the right way round!
23 unshift @INC, "$root/local";
33 use vars qw(@list $fp $today $string);
35 $fp = DXLog::new('debug', 'dat', 'd');
36 $today = $fp->unixtoj(time());
44 } elsif ($arg =~ /^\d+$/) {
51 die "usage: grepdbg [nn] [[-nnn] ..] <regexp>\n" unless $string;
53 push @list, "0" unless @list;
54 for my $entry (@list) {
55 my $now = $today->sub($entry);
56 my $fh = $fp->open($now);
63 shift @prev while @prev > $nolines;
64 if ($line =~ m{$string}io) {
66 s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg;
67 my ($t, $l) = split /\^/, $line, 2;
68 print atime($t), ' ', $l, "\n";