projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed basic usdb stuff
[spider.git]
/
perl
/
DXLogPrint.pm
diff --git
a/perl/DXLogPrint.pm
b/perl/DXLogPrint.pm
index fff39d1256894e6a1765249f0ac157d85fa65b0a..6012d71d065cfa2bec14488d648c1bb68b9a8064 100644
(file)
--- a/
perl/DXLogPrint.pm
+++ b/
perl/DXLogPrint.pm
@@
-8,16
+8,21
@@
package DXLog;
package DXLog;
-use
FileHand
le;
+use
IO::Fi
le;
use DXVars;
use DXVars;
-use DXDebug ();
+
#
use DXDebug ();
use DXUtil;
use DXLog;
use Julian;
use DXUtil;
use DXLog;
use Julian;
-use Carp;
use strict;
use strict;
+use vars qw($VERSION $BRANCH);
+$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
+$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
+$main::build += $VERSION;
+$main::branch += $BRANCH;
+
#
# print some items from the log backwards in time
#
#
# print some items from the log backwards in time
#
@@
-25,50
+30,65
@@
use strict;
#
sub print
{
#
sub print
{
- my $self = $DXLog::log;
- my $from = shift;
- my $to = shift;
- my @date = $self->unixtoj(shift);
+ my $fcb = $DXLog::log;
+ my $from = shift || 0;
+ my $to = shift || 20;
+ my $count;
+ my $jdate = $fcb->unixtoj(shift);
my $pattern = shift;
my $pattern = shift;
+ my $who = uc shift;
my $search;
my @in;
my $search;
my @in;
- my @out;
+ my @out
= ()
;
my $eval;
my $eval;
- my $count;
+ my $tot = $from + $to;
+ my $hint = "";
- $search = $pattern ? "\$ref->[1] =~ /$pattern/" : '1' ;
+ if ($pattern) {
+ $hint = "m{\\Q$pattern\\E}i";
+ } else {
+ $hint = "!m{ann|rcmd|talk}";
+ }
+ if ($who) {
+ if ($hint) {
+ $hint .= ' && ';
+ }
+ $hint .= 'm{\\Q$who\\E}i';
+ }
+ $hint = "next unless $hint" if $hint;
+
$eval = qq(
$eval = qq(
- my \$c;
- my \$ref;
- for (\$c = \$#in; \$c >= 0; \$c--) {
- \$ref = \$in[\$c];
- if ($search) {
- \$count++;
- next if \$count < $from;
- push \@out, print_item(\$ref);
- last LOOP if \$count >= \$to; # stop after n
- }
- }
- );
+ \@in = ();
+ while (<\$fh>) {
+ $hint;
+ chomp;
+ push \@in, \$_;
+ shift \@in, if \@in > $tot;
+ }
+ );
- $
self
->close; # close any open files
+ $
fcb
->close; # close any open files
- my $fh = $self->open(@date);
-LOOP:
- while ($count < $to) {
- my @spots = ();
+ my $fh = $fcb->open($jdate);
+ L1: for ($count = 0; $count < $to; ) {
+ my $ref;
if ($fh) {
if ($fh) {
- while (<$fh>) {
- chomp;
- push @in, [ split '\^' ];
- }
eval $eval; # do the search on this file
eval $eval; # do the search on this file
- return ("Spot search error", $@) if $@;
+ return ("Log search error", $@) if $@;
+ my @tmp;
+ while (@in) {
+ last L1 if $count >= $to;
+ my $ref = [ split /\^/, shift @in ];
+ next if defined $pattern && $ref->[1] ne $pattern;
+ push @tmp, print_item($ref);
+ $count++;
+ }
+ @out = (@tmp, @out);
}
}
- $fh = $
self
->openprev(); # get the next file
+ $fh = $
fcb
->openprev(); # get the next file
last if !$fh;
}
last if !$fh;
}
-
+
return @out;
}
return @out;
}
@@
-98,7
+118,7
@@
sub print_item
} elsif ($ref[1] eq 'talk') {
$s = "$ref[3] -> $ref[2] ($ref[4]) $ref[5]";
} elsif ($ref[1] eq 'ann') {
} elsif ($ref[1] eq 'talk') {
$s = "$ref[3] -> $ref[2] ($ref[4]) $ref[5]";
} elsif ($ref[1] eq 'ann') {
- $s = "$ref[
2] -> $ref[3
] $ref[4]";
+ $s = "$ref[
3] -> $ref[2
] $ref[4]";
} else {
$s = "$ref[2]";
}
} else {
$s = "$ref[2]";
}