]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Add --lastlog and --keeplogs to the command line options
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 27 Nov 2010 21:05:35 +0000 (21:05 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 27 Nov 2010 21:05:35 +0000 (21:05 +0000)
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.

ChangeLog
log.c
sarg.1
sarg_manpage.xml

index fc483e19eede7c055f3ddd62ce277c146e384893..fc0b682caedadce4d179a59acf4ebdf828ea8ca5 100644 (file)
--- 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 3143e165e6b3527ee3320515c81931c7b4afb4d7..42eaec65c94ab993d2e1d98c2a841a5482fabb9e 100644 (file)
--- 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 f2ad341119fc776783aad5762ed83344eb8b8095..dac85963370478512807ab8c73ce77f95da20656 100644 (file)
--- 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
index 590570aa8917122a0716233e8137f727a3b75773..4b90596beeaac106d6c90e77d02dadec083270b7 100644 (file)
@@ -193,6 +193,15 @@ option in config file to contain "users_sites".
 </listitem>
 </varlistentry>
 
+<varlistentry><term><option>--keeplogs</option></term>
+<listitem>
+<para>
+Don't delete any old report. It is equivalent to setting <option>--lastlog 0</option> but is
+provided for convenience.
+</para>
+</listitem>
+</varlistentry>
+
 <varlistentry><term><option>-l <replaceable>filename</replaceable></option></term>
 <listitem>
 <para>
@@ -209,6 +218,16 @@ option. It allows the use of wildcards on the command line. Make sure you don't
 </listitem>
 </varlistentry>
 
+<varlistentry><term><option>--lastlog <replaceable>n</replaceable></option></term>
+<listitem>
+<para>
+Limit the number of logs kept in the output directory to <replaceable>n</replaceable>. Any supernumerary report
+is deleted starting with the oldest report. The value of <replaceable>n</replaceable> must be positive or zero.
+A value of zero means no report should be deleted.
+</para>
+</listitem>
+</varlistentry>
+
 <varlistentry><term><option>-L <replaceable>filename</replaceable></option></term>
 <listitem>
 <para>