]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fix the error messages when parsing a redirector log with custom format
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 4 May 2011 09:34:24 +0000 (09:34 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 4 May 2011 09:34:24 +0000 (09:34 +0000)
If redirector_log_format is set in sarg.conf, the error messages displayed for
any error encountered while parsing the format string are unclear or wrong.
This patch fix the message and explain really why the format string could not
be used.

squidguard_log.c

index 16406b9ad3280b2234d3e45f299db2853b7b478a..325a3ffd3ba241898b27f1e4df6d29a9acc115c0 100644 (file)
@@ -105,7 +105,7 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil)
                        getword_start(&gwarea1,RedirectorLogFormat);
                        leks[0]='\0';
                        if (getword(leks,sizeof(leks),&gwarea1,'#')<0) {
-                               debuga(_("There is a broken record or garbage in your %s file\n"),wentp);
+                               debuga(_("Invalid \"redirector_log_format\" option in your sarg.conf (too many characters before first tag)\n"));
                                exit(EXIT_FAILURE);
                        }
                        year=0;
@@ -118,13 +118,17 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil)
                        user[0]='\0';
                        url[0]='\0';
                        while(strcmp(leks,"end") != 0) {
-                               if (getword(leks,sizeof(leks),&gwarea1,'#')<0 || getword(sep,sizeof(sep),&gwarea1,'#')<0) {
-                                       debuga(_("Maybe you have a broken record or garbage in your %s file\n"),wentp);
+                               if (getword(leks,sizeof(leks),&gwarea1,'#')<0) {
+                                       debuga(_("Invalid \"redirector_log_format\" option in your sarg.conf (missing # at end of tag)\n"));
+                                       exit(EXIT_FAILURE);
+                               }
+                               if (getword(sep,sizeof(sep),&gwarea1,'#')<0) {
+                                       debuga(_("Invalid \"redirector_log_format\" option in your sarg.conf (too many characters in column separator)\n"));
                                        exit(EXIT_FAILURE);
                                }
                                if(strcmp(leks,"end") != 0) {
                                        if (getword_limit(res,sizeof(res),&gwarea,sep[0])<0) {
-                                               debuga(_("Maybe you have a broken record or garbage in your %s file\n"),wentp);
+                                               debuga(_("Parsing of tag \"%s\" in redirector log %s returned no result\n"),leks,wentp);
                                                exit(EXIT_FAILURE);
                                        }
                                        if(strcmp(leks,"year") == 0) {