X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~webstump/git?a=blobdiff_plain;f=xlog%2Fbin%2Freport;h=92a6a5e2793004467b195b4976a09f8cd3bc35d9;hb=HEAD;hp=3c689f0e8ef08c1c816bcb3c96646a883b950601;hpb=789e5a7542eb2245bf9541d9beb798fe704a7ef3;p=modbot-mtm.git diff --git a/xlog/bin/report b/xlog/bin/report index 3c689f0..92a6a5e 100755 --- a/xlog/bin/report +++ b/xlog/bin/report @@ -1,15 +1,37 @@ #!/usr/bin/perl -w -our ($ng,$staticfiles,@ARGV) = @ARGV; -chdir $ng or die $!; - use strict (qw(vars)); use IO::Handle; use POSIX; -use CGI qw/:standard *table end_*/; +use CGI qw/:standard *table end_* -no_xhtml/; + +our $timesquash = 3; +# no. of digits at end of time to replace with x, 0..4 +our %reasonshow = qw(approve 1 reject 1); +# no. of words to show + +for (;;) { + last unless @ARGV; + last unless $ARGV[0] =~ m/^-/; + $_ = shift @ARGV; + last if m/^--?$/; + while (m/^-./) { + if (s/^-t([0-4])/-/) { + $timesquash= $1; + } elsif (s/^-r(\w+)=(\d)$//) { + $reasonshow{$1}= $2; + } else { + die "bad option $_ ?"; + } + } +} + +our ($ng,$staticfiles,@ARGV) = @ARGV; +chdir $ng or die $!; our @lines= (); our @s; +our $oddeven = "o"; our ($processline,$needmap); our ($selectmid,$selectnum); @@ -20,8 +42,14 @@ sub processlog ($$) { while () { chomp; @s= split /\t/; + push @s, '' if @s<=6; $s[0]= strftime "%Y-%m-%d %H:%M:%S %Z", localtime $s[0]; + for (my $i=0; $i<$timesquash; $i++) { + $s[0] =~ s/(\d\d:[\d:]*)\d/$1x/; + } + $s[0] =~ s/:xx / /; &$processline(); + $oddeven =~ y/oe/eo/; } } sub processlogs ($) { @@ -35,6 +63,8 @@ sub processline_print () { my @sp= @s; $sp[3] =~ s/\@\w{0,2}/ at .. /; @sp= map { escapeHTML($_) } @sp[0..5]; + $sp[3] =~ s/</\
</; + $sp[2]=~s/\@/\@<\/span>/; my @spu= map { s/\W/ sprintf "%%%02x", ord $& /ge; $_; @@ -42,14 +72,24 @@ sub processline_print () { if (length $s[1] && length $s[2]) { my $url= url().'/message/'.$spu[1].'/'.$spu[2]; foreach my $i (qw(1 2)) { - $sp[$i]= a({ href=>$url }, $sp[$i] ); + $sp[$i]= a({ href=>$url }, $sp[$i]."
" ); } } if (length $s[6]) { $sp[5]= a({ href=>"$staticfiles/nr-$s[6].txt" }, $sp[5] ); } -#print STDERR join('|',@sp),"\n"; - print Tr(td([@sp])); + + if ($sp[5] =~ m/^\w+\b/ && + defined (my $reasonshow= $reasonshow{$&})) { + my @reas= split /\s+/, $sp[5]; + $reasonshow--; + $#reas = $reasonshow if $#reas > $reasonshow; + $sp[5] = join ' ', @reas; + } + + print "$sp[0]"; + print "$sp[1] $sp[2]"; + print td([@sp[3..5]]),"\n"; } sub processline_print_ifsingle () { @@ -98,12 +138,19 @@ if ($pi =~ m,^/message/(\d+)/(.*)$,) { $processline= \&processline_queue; } -print header(), start_html($title), h1($title), start_table(); +my $css=<$title, -style=>{'-code'=>$css}), + h1($title), start_table(); print Tr(td([map { strong($_) } (qw( Date - Reference - Message-ID + Reference/Message-ID From Subject Event