From: Frédéric Marchal Date: Sat, 27 Nov 2010 21:05:35 +0000 (+0000) Subject: Add --lastlog and --keeplogs to the command line options X-Git-Tag: v2.3.2~124 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c995d3584de87822ea3c7ce516f5ab109bd7c071;p=thirdparty%2Fsarg.git Add --lastlog and --keeplogs to the command line options Those two options supersede the lastlog option from sarg.conf. It is useful to have them on the command line to change the number of reports in the daily, weekly or monthly directories. --- diff --git a/ChangeLog b/ChangeLog index fc483e1..fc0b682 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ SARG ChangeLog -Nov-20-2010 Version 2.3.2-pre1 +Nov-21-2010 Version 2.3.2-pre1 - Add support for sorttable.js (http://www.kryogenix.org/code/browser/sorttable/) to dynamically sort some tables (thanks to Éric). + - Add the two command line options --lastlog and --keeplogs to set the number of reports to keep or to keep all the reports respectively (thanks to Emmanuel Lacour for the suggestion). Sep-18-2010 Version 2.3.1 - Remove the distinct printf for the alpha architecture as it doesn't work anymore and is not necessary anyway. diff --git a/log.c b/log.c index 3143e16..42eaec6 100644 --- a/log.c +++ b/log.c @@ -129,6 +129,7 @@ int main(int argc,char *argv[]) int maxdate=0; int iarq=0; int isa_ncols=0,isa_cols[ISACOL_Last]; + int lastlog=-1; bool from_stdin; bool from_pipe; int blen; @@ -164,6 +165,8 @@ int main(int argc,char *argv[]) { {"convert",no_argument,&convert,1}, {"css",no_argument,&output_css,1}, + {"lastlog",required_argument,NULL,2}, + {"keeplogs",no_argument,NULL,3}, {"split",no_argument,&split,1}, {0,0,0,0} }; @@ -365,6 +368,12 @@ int main(int argc,char *argv[]) { case 0: break; + case 2: + lastlog=atoi(optarg); + break; + case 3: + lastlog=0; + break; case 'a': strcpy(addr,optarg); break; @@ -527,6 +536,8 @@ int main(int argc,char *argv[]) if(dns) Ip2Name=true; + if (lastlog>=0) LastLog=lastlog; + if(realt) { realtime(); exit(EXIT_SUCCESS); @@ -668,6 +679,7 @@ int main(int argc,char *argv[]) debuga(_(" Temporary dir (-w) = %s\n"),tmp); debuga(_(" Debug messages (-x) = %s\n"),(debug) ? _("Yes") : _("No")); debuga(_(" Process messages (-z) = %s\n"),(debugz) ? _("Yes") : _("No")); + debuga(_(" Previous reports to keep (--lastlog) = %d\n"),LastLog); debuga("\n"); } @@ -699,6 +711,7 @@ int main(int argc,char *argv[]) printf(_(" Temporary dir (-w) = %s\n"),tmp); printf(_(" Debug messages (-x) = %s\n"),(debug) ? _("Yes") : _("No")); printf(_(" Process messages (-z) = %s\n"),(debugz) ? _("Yes") : _("No")); + printf(_(" Previous reports to keep (--lastlog) = %d\n"),LastLog); printf(_("sarg version: %s\n"),VERSION); } diff --git a/sarg.1 b/sarg.1 index f2ad341..dac8596 100644 --- a/sarg.1 +++ b/sarg.1 @@ -170,6 +170,13 @@ option in config file to contain "users_sites"\&. .RE .RE .PP +\fB\-\-keeplogs\fR +.RS 4 +Don\'t delete any old report\&. It is equivalent to setting +\fB\-\-lastlog 0\fR +but is provided for convenience\&. +.RE +.PP \fB\-l \fR\fB\fIfilename\fR\fR .RS 4 Uses @@ -188,6 +195,14 @@ sarg 2\&.3, the log files may be named on the command line without the option\&. It allows the use of wildcards on the command line\&. Make sure you don\'t exceed the limit of 255 files\&. .RE .PP +\fB\-\-lastlog \fR\fB\fIn\fR\fR +.RS 4 +Limit the number of logs kept in the output directory to +\fIn\fR\&. Any supernumerary report is deleted starting with the oldest report\&. The value of +\fIn\fR +must be positive or zero\&. A value of zero means no report should be deleted\&. +.RE +.PP \fB\-L \fR\fB\fIfilename\fR\fR .RS 4 Reads a proxy redirector log file such as one created by diff --git a/sarg_manpage.xml b/sarg_manpage.xml index 590570a..4b90596 100644 --- a/sarg_manpage.xml +++ b/sarg_manpage.xml @@ -193,6 +193,15 @@ option in config file to contain "users_sites". + + + +Don't delete any old report. It is equivalent to setting but is +provided for convenience. + + + + @@ -209,6 +218,16 @@ option. It allows the use of wildcards on the command line. Make sure you don't + + + +Limit the number of logs kept in the output directory to n. Any supernumerary report +is deleted starting with the oldest report. The value of n must be positive or zero. +A value of zero means no report should be deleted. + + + +