X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?p=spider.git;a=blobdiff_plain;f=perl%2FDXLogPrint.pm;h=a968e53b1f818d18c9cb467faa1e6b6a98757e57;hp=752e72acd64aaa5470d0d3cae4cb619041d0ed4a;hb=9cc26cc7a73efb7679d3e8e819ba0019307f8607;hpb=20efba5d5f656113144785e0ef84296e6d2c2e69 diff --git a/perl/DXLogPrint.pm b/perl/DXLogPrint.pm index 752e72ac..a968e53b 100644 --- a/perl/DXLogPrint.pm +++ b/perl/DXLogPrint.pm @@ -10,10 +10,11 @@ package DXLog; use IO::File; use DXVars; -#use DXDebug (); +use DXDebug qw(dbg isdbg); use DXUtil; use DXLog; use Julian; +use RingBuf; use strict; @@ -32,7 +33,7 @@ sub print { my $fcb = $DXLog::log; my $from = shift || 0; - my $to = shift || 20; + my $to = shift || 10; my $jdate = $fcb->unixtoj(shift); my $pattern = shift; my $who = uc shift; @@ -46,7 +47,7 @@ sub print if ($pattern) { $hint = "m{\\Q$pattern\\E}i"; } else { - $hint = "!m{ann|rcmd|talk|chat}"; + $hint = "!m{\\^(?:ann|rcmd|talk|chat)\\^}"; } if ($who) { $hint .= ' && ' if $hint; @@ -59,24 +60,30 @@ sub print $eval = qq(while (<\$fh>) { $hint; chomp; - push \@tmp, \$_; + \$ring->write(\$_); } ); + if (isdbg('search')) { + dbg("sh/log hint: $hint"); + dbg("sh/log eval: $eval"); + } + $fcb->close; # close any open files my $fh = $fcb->open($jdate); L1: for (;@in < $to;) { my $ref; + my $ring = RingBuf->new($tot); + if ($fh) { my @tmp; eval $eval; # do the search on this file return ("Log search error", $@) if $@; - @in = (@tmp, @in); - if (@in > $to) { - @in = splice @in, -$to, $to; - last L1; - } + + @in = ($ring->readall, @in); + last L1 if @in > $tot; } + $fh = $fcb->openprev(); # get the next file last if !$fh; } @@ -88,6 +95,7 @@ sub print return @out; } + # # the standard log printing interpreting routine. #