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 my $exp = join '|', @ARGV;
47 shift @prev while @prev > $nolines;
48 if ($line =~ m{(?:$exp)}oi) {
58 # check that the debug hasn't rolled over to next day
60 my @now = Julian::unixtoj(time());
61 if ($today[1] != $now[1]) {
64 for ($i = 0; $i < 20; $i++) {
65 last if $fh = $fp->open(@now);
79 $line =~ s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg;
80 my @line = split '\^', $line;
82 my ($sec,$min,$hour) = gmtime((defined $t) ? $t : time);
83 my $buf = sprintf "%02d:%02d:%02d", $hour, $min, $sec;
85 print $buf, ' ', join('^', @line), "\n";