3 # watch the end of the current debug file (like tail -f) applying
4 # any regexes supplied on the command line.
6 # There can be more than one <regexp>. a <regexp> preceeded by a '!' is
7 # treated as NOT <regexp>. Each <regexp> is implcitly ANDed together.
8 # All <regexp> are caseless.
12 # watchdbg g1tlh # watch everything g1tlh does
13 # watchdbg -2 PCPROT # watch all PCPROT messages + up to 2 lines before
14 # watchdbg gb7baa gb7djk # watch the conversation between BAA and DJK
19 # search local then perl directories
21 # root of directory tree for this system
23 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
25 unshift @INC, "$root/perl"; # this IS the right way round!
26 unshift @INC, "$root/local";
36 my $fp = DXLog::new('debug', 'dat', 'd');
37 my $today = $fp->unixtoj(time());
38 my $fh = $fp->open($today) or die $!;
45 if ($arg =~ /^-+(\d+)/) {
49 usage(), exit(0) if $arg =~ /^-+[h\?]/i;
57 my $line = $fh->getline;
61 shift @prev while @prev > $nolines;
63 foreach my $p (@patt) {
66 last if $line =~ m{$r}i;
68 last unless $line =~ m{$p}i;
82 # check that the debug hasn't rolled over to next day
84 my $now = $fp->unixtoj(time());
85 if ($today->cmp($now)) {
88 for ($i = 0; $i < 20; $i++) {
89 last if $fh = $fp->open($now);
103 $line =~ s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg;
104 my ($t, $l) = split /\^/, $line, 2;
105 $t = time unless defined $t;
106 printf "%02d:%02d:%02d %s\n", (gmtime($t))[2,1,0], $l;
115 usage: watchdbg [-nnn lines before] [<regexp>|!<regexp>]...
117 You can have more than one <regexp> with an implicit 'and' between them. All
118 <regexes> are caseless. It's recommended to put 'not' (!<regex>) first in any list.
119 Don't forget that you are doing this in a shell and you may need to quote your
124 will display any line containing 'progress' and also the two lines before that.