chiark / gitweb /
xlog: New LOGREPORTOPTS for controlling time fudging
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 17 Dec 2014 16:34:47 +0000 (16:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 17 Dec 2014 16:39:14 +0000 (16:39 +0000)
  * Add an option parser to report
  * Provide a new -t option to specify number of digits to squash
  * Default to -t3, meaning show only 10 minute granularity
  * Plumb LOGREPORTOPTS from get-settings, defaulting to ''

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cgi/logs.INO
get-settings
xlog/bin/report

index 5c3510ba262c5ccd8d1eb960c2ac4a94bee06af8..9871e61721538b64c1525ea7356f64db55d58ebe 100755 (executable)
@@ -1,4 +1,4 @@
 #!/bin/bash
 set -e
 cd %BASEDIR%/xlog/log
-exec ../bin/report %GROUP% %STATICFILESURL%/g.%ABBREV%/messages "$@"
+exec ../bin/report %LOGREPORTOPTS% %GROUP% %STATICFILESURL%/g.%ABBREV%/messages "$@"
index 3250905eece6aacaf33aeea436826c35bd7b5ac0..8e2fd03b3aea3c1e08a0a5f058e55c8ea7edda80 100644 (file)
@@ -7,10 +7,11 @@ for k in $pas; do eval "$k=''"; export $k; done
 DIVERTPOSTINGS=''
 MODLOGSEARCH=true
 MODLOGDOWNLOAD=true
+LOGREPORTOPTS=''
 
 . settings
 export GROUP ABBREV INFOHEADER MODEMAIL GROUPURL REJECTIONSLIST
-export DIVERTPOSTINGS MODLOGSEARCH MODLOGDOWNLOAD
+export DIVERTPOSTINGS MODLOGSEARCH MODLOGDOWNLOAD LOGREPORTOPTS
 
 . ../global-settings
 export ROOTBASEDIR CGIBASEURL DOMAIN SLIMYDOMAIN OURUSER ADMIN
index aef8458c91932a5d164a0d25ca146a7823fa989d..f6ea1d160de4d94c87e96b0220e9651d4f3c23e3 100755 (executable)
@@ -1,13 +1,30 @@
 #!/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_* -no_xhtml/;
 
+our $timesquash = 3;
+# no. of digits at end of time to replace with x, 0..4
+
+for (;;) {
+    last unless @ARGV;
+    last unless $ARGV[0] =~ m/^-/;
+    $_ = shift @ARGV;
+    last if m/^--?$/;
+    while (m/^-./) {
+       if (s/^-t([0-4])/-/) {
+           $timesquash= $1;
+       } else {
+           die "bad option $_ ?";
+       }
+    }
+}
+
+our ($ng,$staticfiles,@ARGV) = @ARGV;
+chdir $ng or die $!;
+
 our @lines= ();
 our @s;
 our $oddeven = "o";
@@ -22,8 +39,11 @@ sub processlog ($$) {
        chomp;
        @s= split /\t/;
        push @s, '' if @s<=6;
-        $s[0]= strftime "%Y-%m-%d %H:%M %Z", localtime $s[0];
-        $s[0] =~ s/(\d+\:\d)\d/${1}x/;
+        $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/;
     }