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 $!;
40 $nolines = shift if $ARGV[0] =~ /^-?\d+$/;
41 $nolines = abs $nolines if $nolines < 0;
48 my $line = $fh->getline;
52 shift @prev while @prev > $nolines;
54 foreach my $p (@patt) {
57 last if $line =~ m{$r}i;
59 last unless $line =~ m{$p}i;
73 # check that the debug hasn't rolled over to next day
75 my $now = $fp->unixtoj(time());
76 if ($today->cmp($now)) {
79 for ($i = 0; $i < 20; $i++) {
80 last if $fh = $fp->open($now);
94 $line =~ s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg;
95 my ($t, $l) = split /\^/, $line, 2;
96 $t = time unless defined $t;
97 printf "%02d:%02d:%02d %s\n", (gmtime($t))[2,1,0], $l;