X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXLogPrint.pm;h=6d37cb415d16ddfba84d481aa69055e881f653d2;hb=b50b7a1c99679f3624852f29068a6cde268e9560;hp=3c0203575d978e3355bd95b41df023268080a98f;hpb=97315924f561c56cef3b581691409d4217f5c1b5;p=spider.git diff --git a/perl/DXLogPrint.pm b/perl/DXLogPrint.pm index 3c020357..6d37cb41 100644 --- a/perl/DXLogPrint.pm +++ b/perl/DXLogPrint.pm @@ -10,11 +10,10 @@ package DXLog; use IO::File; use DXVars; -use DXDebug (); +#use DXDebug (); use DXUtil; use DXLog; use Julian; -use Carp; use strict; @@ -25,25 +24,44 @@ 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; + my $hint = ""; - $search = '1' unless $pattern || $who; - $search = "\$ref->[1] =~ /$pattern/" if $pattern; - $search .= ' && ' if $pattern && $who; - $search .= "(\$ref->[2] =~ /$who/ || \$ref->[3] =~ /$who/)" if $who; + if ($pattern) { + $search = "\$ref->[1] =~ m{^$pattern}i"; + $hint = "m{$pattern}i"; + } + if ($who) { + if ($search) { + $search .= ' && '; + $hint .= ' && '; + } + $search .= "(\$ref->[2] =~ m{$who}i || \$ref->[3] =~ m{$who}i)"; + $hint .= 'm{$who}i'; + } + $hint = "next unless $hint" if $hint; + $search = "1" unless $search; + $eval = qq( + \@in = (); + while (<\$fh>) { + $hint; + chomp; + \$ref = [ split '\\^' ]; + push \@\$ref, "" unless \@\$ref >= 4; + push \@in, \$ref; + } my \$c; - my \$ref; for (\$c = \$#in; \$c >= 0; \$c--) { \$ref = \$in[\$c]; if ($search) { @@ -55,25 +73,21 @@ sub print } ); - $self->close; # close any open files + $fcb->close; # close any open files - my $fh = $self->open(@date); + my $fh = $fcb->open(@date); for ($count = 0; $count < $to; ) { - my @spots = (); + my $ref; if ($fh) { - while (<$fh>) { - chomp; - push @in, [ split '\^' ]; - } eval $eval; # do the search on this file 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 if defined @out; + return @out; } #