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
15 # search local then perl directories
17 # root of directory tree for this system
19 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
21 unshift @INC, "$root/perl"; # this IS the right way round!
22 unshift @INC, "$root/local";
32 my $fp = DXLog::new('debug', 'dat', 'd');
33 my @today = Julian::unixtoj(time());
34 my $fh = $fp->open(@today) or die $!;
36 $nolines = shift if $ARGV[0] =~ /^-?\d+$/;
37 $nolines = abs $nolines if $nolines < 0;
38 my $exp = join '|', @ARGV;
48 shift @prev while @prev > $nolines;
49 if ($line =~ m{(?:$exp)}oi) {
59 # check that the debug hasn't rolled over to next day
61 my @now = Julian::unixtoj(time());
62 if ($today[1] != $now[1]) {
65 for ($i = 0; $i < 20; $i++) {
66 last if $fh = $fp->open(@now);
80 $line =~ s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg;
81 my ($t, $l) = split /\^/, $line, 2;
82 my ($sec,$min,$hour) = gmtime((defined $t) ? $t : time);
83 my $buf = sprintf "%02d:%02d:%02d", $hour, $min, $sec;
85 print $buf, ' ', $l, "\n";