X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXLogPrint.pm;h=185912cda4948abefe7d3408da3d371651921417;hb=c20a2c1e01d707d6c3fa25067df93d491aba8fff;hp=54cfc516b2173a2ea850ff3b585d4976df25eaaf;hpb=b0f75ae15722922dc8f341a2de79106326ff7575;p=spider.git diff --git a/perl/DXLogPrint.pm b/perl/DXLogPrint.pm index 54cfc516..185912cd 100644 --- a/perl/DXLogPrint.pm +++ b/perl/DXLogPrint.pm @@ -8,13 +8,12 @@ package DXLog; -use FileHandle; +use IO::File; use DXVars; -use DXDebug (); +#use DXDebug (); use DXUtil; use DXLog; use Julian; -use Carp; use strict; @@ -25,18 +24,22 @@ use strict; # sub print { - my $self = $DXLog::log; + my $fcb = $DXLog::log; my $from = shift; my $to = shift; - my @date = $self->unixtoj(shift); + my @date = Julian::unixtojm(shift); my $pattern = shift; + my $who = uc shift; my $search; my @in; - my @out; + my @out = (); my $eval; my $count; - $search = $pattern ? "\$ref->[1] =~ /$pattern/" : '1' ; + $search = '1' unless $pattern || $who; + $search = "\$ref->[1] =~ /$pattern/i" if $pattern; + $search .= ' && ' if $pattern && $who; + $search .= "(\$ref->[2] =~ /$who/i || \$ref->[3] =~ /$who/i)" if $who; $eval = qq( my \$c; my \$ref; @@ -46,29 +49,32 @@ sub print \$count++; next if \$count < $from; push \@out, print_item(\$ref); - last LOOP if \$count >= \$to; # stop after n + last if \$count >= \$to; # stop after n } } ); - $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(@date); + for ($count = 0; $count < $to; ) { + my $ref; if ($fh) { + @in = (); while (<$fh>) { chomp; - push @in, [ split '\^' ]; + $ref = [ split '\^' ]; + push @{$ref}, "" unless @{$ref} >= 4; + push @in, $ref; } eval $eval; # do the search on this file - return ("Spot search error", $@) if $@; + last if $count >= $to; # stop after n + return ("Log search error", $@) if $@; } - $fh = $self->openprev(); # get the next file + $fh = $fcb->openprev(); # get the next file last if !$fh; } - + return @out; }