2 # Log Printing routines
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
20 use vars qw($VERSION $BRANCH);
21 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
22 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
23 $main::build += $VERSION;
24 $main::branch += $BRANCH;
27 # print some items from the log backwards in time
29 # This command outputs a list of n lines starting from time t with $pattern tags
33 my $fcb = $DXLog::log;
34 my $from = shift || 0;
36 my $jdate = $fcb->unixtoj(shift);
43 my $tot = $from + $to;
47 $hint = "m{\\Q$pattern\\E}i";
49 $hint = "!m{ann|rcmd|talk}";
52 $hint .= ' && ' if $hint;
53 $hint .= 'm{\\Q$who\\E}i';
55 $hint = "next unless $hint" if $hint;
56 $hint .= ";next unless /^\\d+\\^$pattern\\^/" if $pattern;
59 $eval = qq(while (<\$fh>) {
65 $fcb->close; # close any open files
67 my $fh = $fcb->open($jdate);
68 L1: for (;@in < $to;) {
72 eval $eval; # do the search on this file
73 return ("Log search error", $@) if $@;
76 @in = splice @in, -$to, $to;
80 $fh = $fcb->openprev(); # get the next file
84 my @line = split /\^/ ;
85 push @out, print_item(\@line);
92 # the standard log printing interpreting routine.
94 # every line that is printed should call this routine to be actually visualised
96 # Don't really know whether this is the correct place to put this stuff, but where
99 # I get a reference to an array of items
104 my $d = atime($r->[0]);
107 if ($r->[1] eq 'rcmd') {
108 if ($r->[2] eq 'in') {
110 $s = "$r->[4] (priv: $r->[3]) rcmd: $r->[5]";
113 $s = "$r->[3] reply: $r->[4]";
115 } elsif ($r->[1] eq 'talk') {
117 $s = "$r->[3] -> $r->[2] ($r->[4]) $r->[5]";
118 } elsif ($r->[1] eq 'ann') {
120 $s = "$r->[3] -> $r->[2] $r->[4]";