]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Don't display the period covered by the logs if it is empty
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Tue, 9 Jun 2015 17:45:21 +0000 (19:45 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Tue, 9 Jun 2015 17:45:21 +0000 (19:45 +0200)
Sarg outputs a line with the earliest and latest dates found if the logs
but it displays 00/01/00 if no log was found. It is best not to display
anything in that case.

include/defs.h
log.c
readlog.c

index 369b56aed8440a12c69f34141dc7882ac8838d07..012a80100ef5cf4a1edb39a932d55830997b6170 100644 (file)
@@ -262,7 +262,7 @@ void make_index(void);
 
 // readlog.c
 int ReadLogFile(struct ReadLogDataStruct *Filter);
-void GetLogPeriod(struct tm *Start,struct tm *End);
+bool GetLogPeriod(struct tm *Start,struct tm *End);
 
 // realtime.c
 void realtime(void);
diff --git a/log.c b/log.c
index 30561a0a8c148099fb285bc19727a19f74995bea..027a9635bde2ee6d80c762f2243ab109858d0f54 100644 (file)
--- a/log.c
+++ b/log.c
@@ -682,11 +682,12 @@ int main(int argc,char *argv[])
                char date0[30], date1[30];
                struct tm Start,End;
 
-               GetLogPeriod(&Start,&End);
-               strftime(date0,sizeof(date0),"%x",&Start);
-               strftime(date1,sizeof(date1),"%x",&End);
-               // TRANSLATORS: The %s are the start and end dates in locale format.
-               debuga(__FILE__,__LINE__,_("Period covered by log files: %s-%s\n"),date0,date1);
+               if (GetLogPeriod(&Start,&End)) {
+                       strftime(date0,sizeof(date0),"%x",&Start);
+                       strftime(date1,sizeof(date1),"%x",&End);
+                       // TRANSLATORS: The %s are the start and end dates in locale format.
+                       debuga(__FILE__,__LINE__,_("Period covered by log files: %s-%s\n"),date0,date1);
+               }
        }
 
        if (!LogStatus){
index dcbd2202e8c7dd354815e324bb7b929257408c2f..31e307ba13947d5ed36ee20cc15f3e2bbf90f151 100644 (file)
--- a/readlog.c
+++ b/readlog.c
@@ -896,16 +896,21 @@ int ReadLogFile(struct ReadLogDataStruct *Filter)
 /*!
  * Get the start and end date of the period covered by the log files.
  */
-void GetLogPeriod(struct tm *Start,struct tm *End)
+bool GetLogPeriod(struct tm *Start,struct tm *End)
 {
+       bool Valid=false;
+
        if (EarliestDate>=0) {
                memcpy(Start,&EarliestDateTime,sizeof(struct tm));
+               Valid=true;
        } else {
                memset(Start,0,sizeof(struct tm));
        }
        if (LatestDate>=0) {
                memcpy(End,&LatestDateTime,sizeof(struct tm));
+               Valid=true;
        } else {
                memset(End,0,sizeof(struct tm));
        }
+       return(Valid);
 }