projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
the last warnings??
[spider.git]
/
perl
/
DXLogPrint.pm
diff --git
a/perl/DXLogPrint.pm
b/perl/DXLogPrint.pm
index 8ce8e35c535492b6ec1a1dbe9f6a3176de191d08..92deee427026cf1e574b3a66c5d479a88131304f 100644
(file)
--- a/
perl/DXLogPrint.pm
+++ b/
perl/DXLogPrint.pm
@@
-3,27
+3,32
@@
#
# Copyright (c) - 1998 Dirk Koopman G1TLH
#
#
# Copyright (c) - 1998 Dirk Koopman G1TLH
#
-#
$Id$
+#
#
package DXLog;
#
package DXLog;
+use 5.10.1;
+
use IO::File;
use DXVars;
use DXDebug qw(dbg isdbg);
use DXUtil;
use DXLog;
use Julian;
use IO::File;
use DXVars;
use DXDebug qw(dbg isdbg);
use DXUtil;
use DXLog;
use Julian;
-use RingBuf;
-use strict;
-use vars qw($VERSION $BRANCH $maxmonths);
-$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;
+our $readback = 1;
+if ($readback) {
+ $readback = `which tac`;
+}
+chomp $readback;
+#undef $readback; # yet another reason not to use the cloud!
+
+use strict;
+
+use vars qw($maxmonths);
$maxmonths = 36;
#
$maxmonths = 36;
#
@@
-31,14
+36,14
@@
$maxmonths = 36;
#
# This command outputs a list of n lines starting from time t with $pattern tags
#
#
# This command outputs a list of n lines starting from time t with $pattern tags
#
-sub
print
+sub
search
{
my $fcb = $DXLog::log;
{
my $fcb = $DXLog::log;
- my $from = shift
||
0;
- my $to = shift
||
10;
+ my $from = shift
//
0;
+ my $to = shift
//
10;
my $jdate = $fcb->unixtoj(shift);
my $pattern = shift;
my $jdate = $fcb->unixtoj(shift);
my $pattern = shift;
- my $who =
uc
shift;
+ my $who = shift;
my $search;
my @in;
my @out = ();
my $search;
my @in;
my @out = ();
@@
-46,23
+51,29
@@
sub print
my $tot = $from + $to;
my $hint = "";
my $tot = $from + $to;
my $hint = "";
+ $who = uc $who if defined $who;
+
+ dbg("from: $from to: $to pattern: $pattern hint: $hint") if isdbg('search');
+
if ($pattern) {
if ($pattern) {
- $hint =
"m{\\Q$pattern\\E}i"
;
+ $hint =
qq{m{\Q$pattern\E}i}
;
} else {
} else {
- $hint =
"!m{\\^(?:ann|rcmd|talk|chat)\\^}"
;
+ $hint =
q{!m{\^(?:ann|rcmd|talk|chat)\^}}
;
}
if ($who) {
$hint .= ' && ' if $hint;
}
if ($who) {
$hint .= ' && ' if $hint;
- $hint .=
'm{\\Q$who\\E}i'
;
+ $hint .=
q{m{\Q$who\E}i}
;
}
$hint = "next unless $hint" if $hint;
}
$hint = "next unless $hint" if $hint;
- $hint .= ";
next unless /^\\d+\\^$pattern\\^/
" if $pattern;
+ $hint .= ";
next unless m{^\\d+\\^$pattern\\^}i
" if $pattern;
$hint ||= "";
$eval = qq(while (<\$fh>) {
$hint;
chomp;
$hint ||= "";
$eval = qq(while (<\$fh>) {
$hint;
chomp;
- \$ring->write(\$_);
+ # say "line: \$_";
+ push \@in, \$_;
+ last L1 if \@in >= $tot;
} );
if (isdbg('search')) {
} );
if (isdbg('search')) {
@@
-73,30
+84,50
@@
sub print
$fcb->close; # close any open files
my $months;
$fcb->close; # close any open files
my $months;
- my $fh = $fcb->open($jdate);
- L1: for ($months = 0; $months < $maxmonths && @in < $tot; $months++) {
+ my $fh;
+ if ($readback) {
+ my $fn = $fcb->fn($jdate);
+ $fh = IO::File->new("$readback $fn |");
+ } else {
+ $fh = $fcb->open($jdate);
+ }
+ L1: for ($months = 0; $fh && $months < $maxmonths && @in < $tot; $months++) {
my $ref;
my $ref;
- my $ring = RingBuf->new($tot);
if ($fh) {
my @tmp;
eval $eval; # do the search on this file
return ("Log search error", $@) if $@;
if ($fh) {
my @tmp;
eval $eval; # do the search on this file
return ("Log search error", $@) if $@;
-
- @in = ($ring->readall, @in);
- last L1 if @in > $tot;
}
}
- $fh = $fcb->openprev(); # get the next file
- last if !$fh;
+ if ($readback) {
+ my $fn = $fcb->fn($jdate->sub(1));
+ $fh = IO::File->new("$readback $fn |");
+ } else {
+ $fh = $fcb->openprev(); # get the next file
+ }
}
}
-
- @in = splice @in, -$tot, $tot if @in > $tot;
-
+
+ unless (@in) {
+ my $name = $pattern ? $pattern : "log";
+ my $s = "$who "|| '';
+ return "show/$name: ${s}not found";
+ }
+
+ for (sort {$a cmp $b } @in) {
+ push @out, [ split /\^/ ]
+ }
+
+ return @out;
+}
+
+sub print
+{
+ my @out;
+
+ my @in = search(@_);
for (@in) {
for (@in) {
- my @line = split /\^/ ;
- push @out, print_item(\@line);
-
+ push @out, print_item($_);
}
return @out;
}
}
return @out;
}
@@
-119,12
+150,13
@@
sub print_item
my $s = 'undef';
if ($r->[1] eq 'rcmd') {
my $s = 'undef';
if ($r->[1] eq 'rcmd') {
+ $r->[6] ||= 'Unknown';
if ($r->[2] eq 'in') {
$r->[5] ||= "";
if ($r->[2] eq 'in') {
$r->[5] ||= "";
- $s = "
$r->[4] (
priv: $r->[3]) rcmd: $r->[5]";
+ $s = "
in: $r->[4] ($r->[6]
priv: $r->[3]) rcmd: $r->[5]";
} else {
$r->[4] ||= "";
} else {
$r->[4] ||= "";
- $s = "$r->[3] reply: $r->[4]";
+ $s = "$r->[3]
$r->[6]
reply: $r->[4]";
}
} elsif ($r->[1] eq 'talk') {
$r->[5] ||= "";
}
} elsif ($r->[1] eq 'talk') {
$r->[5] ||= "";