From 87c1744952c472b438731e0022c5bcb4709eac3d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 17 Dec 2014 16:34:47 +0000 Subject: [PATCH] xlog: New LOGREPORTOPTS for controlling time fudging * 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 --- cgi/logs.INO | 2 +- get-settings | 3 ++- xlog/bin/report | 30 +++++++++++++++++++++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/cgi/logs.INO b/cgi/logs.INO index 5c3510b..9871e61 100755 --- a/cgi/logs.INO +++ b/cgi/logs.INO @@ -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 "$@" diff --git a/get-settings b/get-settings index 3250905..8e2fd03 100644 --- a/get-settings +++ b/get-settings @@ -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 diff --git a/xlog/bin/report b/xlog/bin/report index aef8458..f6ea1d1 100755 --- a/xlog/bin/report +++ b/xlog/bin/report @@ -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/; } -- 2.30.2