3 # watch the end of the current debug file (like tail -f) applying
4 # any regexes supplied on the command line.
8 # watchdbg g1tlh # watch everything g1tlh does
9 # watchdbg 2 PCPROT # watch all PCPROT messages + up to 2 lines before
10 # watchdbg gb7baa gb7djk # watch the conversation between BAA and DJK
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";
35 my $fp = DXLog::new('debug', 'dat', 'd');
36 my $today = $fp->unixtoj(time());
37 my $fh = $fp->open($today) or die $!;
39 $nolines = shift if $ARGV[0] =~ /^-?\d+$/;
40 $nolines = abs $nolines if $nolines < 0;
41 my $exp = join '|', @ARGV;
51 shift @prev while @prev > $nolines;
52 if ($line =~ m{(?:$exp)}oi) {
62 # check that the debug hasn't rolled over to next day
64 my $now = $fp->unixtoj(time());
65 if ($today->cmp($now)) {
68 for ($i = 0; $i < 20; $i++) {
69 last if $fh = $fp->open($now);
83 $line =~ s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg;
84 my ($t, $l) = split /\^/, $line, 2;
85 my ($sec,$min,$hour) = gmtime((defined $t) ? $t : time);
86 my $buf = sprintf "%02d:%02d:%02d", $hour, $min, $sec;
88 print $buf, ' ', $l, "\n";