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 gb7baa gb7djk # watch the conversation between BAA and DJK
14 # search local then perl directories
16 # root of directory tree for this system
18 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
20 unshift @INC, "$root/perl"; # this IS the right way round!
21 unshift @INC, "$root/local";
31 my $fp = DXLog::new('debug', 'dat', 'd');
32 my @today = Julian::unixtoj(time());
33 my $fh = $fp->open(@today) or die $!;
34 my $nolines = shift if $ARGV[0] =~ /^\d+$/ || 1;
35 my $exp = join '|', @ARGV;
45 shift @prev while @prev > $nolines;
46 if ($line =~ m{(?:$exp)}oi) {
56 # check that the debug hasn't rolled over to next day
58 my @now = Julian::unixtoj(time());
59 if ($today[1] != $now[1]) {
62 for ($i = 0; $i < 20; $i++) {
63 last if $fh = $fp->open(@now);
77 $line =~ s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg;
78 my @line = split '\^', $line;
80 my ($sec,$min,$hour) = gmtime((defined $t) ? $t : time);
81 my $buf = sprintf "%02d:%02d:%02d", $hour, $min, $sec;
83 print $buf, ' ', join('^', @line), "\n";