3 # Program to do a grep with dates and times on the debug
6 # grepdbg [nn] [-mm] <regular expression>
9 # nn - is the day you what to look at: 1 is yesterday, 0 is today
10 # and is optional if there is only one argument
12 # -mmm - print the mmm lines before the match. So -10 will print
13 # ten lines including the line matching the regular expression.
15 # <regexp> is the regular expression you are searching for,
16 # a caseless search is done
22 # search local then perl directories
24 # root of directory tree for this system
26 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
28 unshift @INC, "$root/perl"; # this IS the right way round!
29 unshift @INC, "$root/local";
40 use vars qw(@list $fp $today $string);
42 $fp = DXLog::new('debug', 'dat', 'd');
43 $today = $fp->unixtoj(time());
51 } elsif ($arg =~ /^\d+$/) {
58 die "usage: grepdbg [nn] [[-nnn] ..] <regexp>\n" unless $string;
60 push @list, "0" unless @list;
61 for my $entry (@list) {
62 my $now = $today->sub($entry);
63 my $fh = $fp->open($now);
70 shift @prev while @prev > $nolines;
71 if ($line =~ m{$string}io) {
73 s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg;
74 my ($t, $l) = split /\^/, $_, 2;
75 print atime($t), ' ', $l, "\n";