]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Display some messages to understand why sarg isn't doing something
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 30 Oct 2011 14:42:42 +0000 (14:42 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 30 Oct 2011 14:42:42 +0000 (14:42 +0000)
One common class of questions from users is to ask why sarg isn't
producing some kind of report. Considering the number of configuration
parameters, it is not surprising that some users get lost.

To help the users help themselves, the -z command line option has been
enhanced to print messages indicating why sarg don't produce a report.

17 files changed:
CMakeLists.txt
authfail.c
dansguardian_log.c
dansguardian_report.c
denied.c
documentation/util.txt
download.c
html.c
include/defs.h
include/info.h
log.c
redirector.c
report.c
siteuser.c
topsites.c
topuser.c
util.c

index 4ec2ef572ef41a88fdff350ceeeaec7de283e095..24a870d28f0e273a3d362af76752e4d028723c4e 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION "3.2-pre2")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Sep-14-2011")
+SET(sarg_BUILDDATE "Oct-30-2011")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
index 219fe0906db12cb4c7ba28889fee27995c619d7d..8e74f78487f339c16765e08a38f1662c724cc48e 100644 (file)
@@ -72,6 +72,7 @@ void authfail_report(void)
 
        if(authfail_count == 0) {
                unlink(tmp4);
+               if (debugz) debugaz(_("Authentication failures report not produced because it is empty\n"));
                return;
        }
 
index 203d603aacf94a26c2d817d301e3cbc183e8d8cb..92764c0447768c2912817fdd68819c4edf246737 100644 (file)
@@ -77,6 +77,8 @@ void dansguardian_log(void)
                                debuga(_("Maybe you have a broken record or garbage in your %s file\n"),DansGuardianConf);
                                exit(EXIT_FAILURE);
                        }
+                       if (debug) debuga(_("Using the dansguardian log file \"%s\" found in your configuration file \"%s\"\n"),
+                               loglocation,DansGuardianConf);
                        break;
                }
        }
index 60d83e1aad5b3b6ccf25ada50c993483a1873a08..0bf7b48f374a5ff021fb237c0298caf81b0d05fa 100644 (file)
@@ -61,6 +61,7 @@ void dansguardian_report(void)
        snprintf(dansguardian_in,sizeof(dansguardian_in),"%s/dansguardian.log",tmp);
        if(!dansguardian_count) {
                unlink(dansguardian_in);
+               if (debugz) debugaz(_("Dansguardian report not generated because it is empty\n"));
                return;
        }
 
index 3800600d1588682398b97103303d6b90f99667c4..ec8505cc294b59dd25710920875730979e3fd2aa 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -65,6 +65,7 @@ void gen_denied_report(void)
        sprintf(denied_in,"%s/denied.log",tmp);
        if (!denied_count) {
                unlink(denied_in);
+               if (debugz) debugaz(_("Denied report not produced because it is empty\n"));
                return;
        }
 
index 508d36b457b63ecd2a521097f73a8a7e093d8bc4..cfdc9af455d5bd9971f15db961873b71c9d921fe 100644 (file)
@@ -268,29 +268,6 @@ Get the name of the month according to the language file selected by the user.
 
 
 
-/*! \fn void debuga(const char *msg,...)
-Write a debug message to stderr. The message is prefixed by "SARG:" to identify its origin.
-
-\param msg The printf like message to format.
-\param ... The arguments to format in the message.
-
-*/
-
-
-
-
-
-/*! \fn void debugaz(const char *head, const char *msg)
-Write a debug message to stderr with the value of a parameter. The message is prefixed by "SARG: (util)".
-
-\param head The name of the parameter.
-\param msg The value of the parameter.
-*/
-
-
-
-
-
 /*! \fn char *fixnum(long long int value, int n)
 Rewrite a number to make it more readable. The number may be written
 with the suffix K, M, G or T depending on its magnitude or the digits
index 192b29b63be9479c75a860e08a849d32cdf5ec8b..b424a0a67e73ceb8179cf6269687d5e5c8f83ee4 100644 (file)
@@ -60,8 +60,10 @@ void download_report(void)
        ouser2[0]='\0';
 
        snprintf(report_in,sizeof(report_in),"%s/download.log",tmp);
-       if(access(report_in, R_OK) != 0)
+       if(access(report_in, R_OK) != 0) {
+               if (debugz) debugaz(_("Downloaded files report not generated as it is empty\n"));
                return;
+       }
 
        snprintf(report,sizeof(report),"%s/download.html",outdirname);
 
diff --git a/html.c b/html.c
index 14a2dbe7a887923e2bd68726471ee67a023b28e0..e77669e16450760da49e23fb2cb3252b32beb9ca 100644 (file)
--- a/html.c
+++ b/html.c
@@ -62,8 +62,6 @@ void htmlrel(void)
        const struct userinfostruct *uinfo;
        userscan uscan;
 
-       if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
-
        if (snprintf(tmp2,sizeof(tmp2),"%s/sargtmp.unsort",tmp)>=sizeof(tmp2)) {
                debuga(_("File name too long: %s/sargtmp.unsort\n"),tmp);
                exit(EXIT_FAILURE);
index 3931f575cbbe25a0a60909f5882c7f2d441db6e2..9ddd29d3d2a9e02cb818707aa9c203fd83df8c00 100755 (executable)
@@ -248,7 +248,7 @@ void output_html_string(FILE *fp_ou,const char *str,int maxlen);
 void output_html_url(FILE *fp_ou,const char *url);
 void output_html_link(FILE *fp_ou,const char *url,int maxlen);
 void debuga(const char *msg,...) __attribute__((format(printf,1,2)));
-void debugaz(const char *head, const char *msg);
+void debugaz(const char *msg,...) __attribute__((format(printf,1,2)));
 void my_lltoa(unsigned long long int n, char *s, int ssize, int len);
 char *get_size(const char *path, const char *file);
 void url_module(const char *url, char *w2);
index 27b518adbf641f33da2895dec35192e497dd4dc5..c4acc1abfcc8131fa54769e5123337886c953884 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Sep-14-2011"
+#define VERSION PACKAGE_VERSION" Oct-30-2011"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
diff --git a/log.c b/log.c
index 4e1265a6839137d5f1b501ad5b32ee39ef70d39d..b1d14d24d8291c4f2d66d68de5b69982ebea943e 100644 (file)
--- a/log.c
+++ b/log.c
@@ -1626,8 +1626,8 @@ int main(int argc,char *argv[])
        }
 
        if(debugz){
-               debugaz("data",dia);
-               debugaz("period",period.text);
+               debugaz(_("date=%s\n"),dia);
+               debugaz(_("period=%s\n"),period.text);
        }
 
        if(debug)
index 34b5591f2a3f00d95ae43f0a9ec5a7e2ab6dee0f..f85553fdb5b97f266c4004a66788b06336ecd6f9 100644 (file)
@@ -277,8 +277,10 @@ void redirector_log(void)
 
        str2 = user;
 
-       if(SquidGuardConf[0] == '\0' && NRedirectorLogs == 0)
+       if(SquidGuardConf[0] == '\0' && NRedirectorLogs == 0) {
+               if (debugz) debugaz(_("No redirector logs provided to produce that kind of report\n"));
                return;
+       }
 
        sprintf(guard_in,"%s/redirector.unsort",tmp);
        sprintf(guard_ou,"%s/redirector.log",tmp);
@@ -422,6 +424,7 @@ void redirector_report(void)
        sprintf(squidguard_in,"%s/redirector.log",tmp);
        if(!redirector_count) {
                unlink(squidguard_in);
+               if (debugz) debugaz(_("Redirector report not generated because it is empty\n"));
                return;
        }
 
index c54bdc6dc888ba8e125ffdd751f72731883c6a1b..6dcee293339443187e43d3ec69ccd22e14607570 100644 (file)
--- a/report.c
+++ b/report.c
@@ -92,7 +92,7 @@ void gerarel(void)
        }
 
        if(debugz){
-               debugaz("outdirname",outdirname);
+               debugaz(_("outdirname=%s\n"),outdirname);
        }
 
        if(UserAgentLog[0] != '\0' && email[0] == '\0') useragent();
@@ -349,15 +349,22 @@ void gerarel(void)
        fclose(fp_gen);
        if (puinfo && !indexonly) day_totalize(tmp,puinfo);
 
-       if (!indexonly) tmpsort();
+       if (!indexonly)
+               tmpsort();
+       else if (debugz)
+               debugaz(_("Only the index is generated as requested\n"));
 
        if(email[0] == '\0') {
                if (!indexonly) {
-                       if((ReportType & REPORT_TYPE_DOWNLOADS) != 0) download_report();
+                       if((ReportType & REPORT_TYPE_DOWNLOADS) != 0)
+                               download_report();
+                       else if (debugz)
+                               debugaz(_("Downloaded files report not requested in report_type\n"));
 
-                       if(DansGuardianConf[0] != '\0') {
+                       if(DansGuardianConf[0] != '\0')
                                dansguardian_log();
-                       }
+                       else if (debugz)
+                               debugaz(_("Dansguardian report not produced because no dansguardian configuration file was provided\n"));
 
                        redirector_log();
                }
@@ -365,23 +372,37 @@ void gerarel(void)
                topuser();
 
                if (!indexonly) {
-                       if((ReportType & REPORT_TYPE_TOPSITES) != 0) topsites();
-
-                       if((ReportType & REPORT_TYPE_SITES_USERS) != 0) siteuser();
+                       if((ReportType & REPORT_TYPE_TOPSITES) != 0)
+                               topsites();
+                       else if (debugz)
+                               debugaz(_("Top sites report not requested in report_type\n"));
+
+                       if((ReportType & REPORT_TYPE_SITES_USERS) != 0)
+                               siteuser();
+                       else if (debugz)
+                               debugaz(_("Sites & users report not requested in report_type\n"));
                        
                        if ((ReportType & REPORT_TYPE_DENIED) != 0)
                                gen_denied_report();
+                       else if (debugz)
+                               debugaz(_("Denied accesses report not requested in report_type\n"));
 
                        if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0)
                                authfail_report();
+                       else if (debugz)
+                               debugaz(_("Authentication failures report not requested in report_type\n"));
 
                        if(smartfilter) smartfilter_report();
 
-                       if(DansGuardianConf[0] != '\0') dansguardian_report();
+                       if(DansGuardianConf[0] != '\0')
+                               dansguardian_report();
 
                        redirector_report();
 
-                       if((ReportType & REPORT_TYPE_USERS_SITES) != 0) htmlrel();
+                       if((ReportType & REPORT_TYPE_USERS_SITES) != 0)
+                               htmlrel();
+                       else if (debugz)
+                               debugaz(_("User's detailed report not requested in report_type\n"));
                }
 
                make_index();
index 09c220b4a17c2332d61019e9ccd8a472d73d8e7b..02df1f6095e121f9245567c2369871ce3375543a 100644 (file)
@@ -50,8 +50,10 @@ void siteuser(void)
        struct generalitemstruct item;
        const struct userinfostruct *uinfo;
 
-       if(Privacy)
+       if(Privacy) {
+               if (debugz) debugaz(_("Sites and users report not generated because privacy option is on\n"));
                return;
+       }
 
        nsitesusers = 0;
        sprintf(general,"%s/sarg-general",outdirname);
index 9ab48de0c55fc271803e595e1ccf5eb894ba927e..e361331676fd8587fd159d620ffbd5773eb67b26 100644 (file)
@@ -66,8 +66,10 @@ void topsites(void)
        longline line;
        struct generalitemstruct item;
 
-       if(Privacy)
+       if(Privacy) {
+               if (debugz) debugaz(_("Top sites report not produced because privacy option is on\n"));
                return;
+       }
 
        sprintf(general,"%s/sarg-general",outdirname);
        sprintf(sites,"%s/sarg-sites",outdirname);
index 2e5d348152ad7f243f7791969adeec7bb2eb81c9..2148c8508624ed26274223b18d14fb5eb7a38157 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -222,6 +222,7 @@ void topuser(void)
        if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) {
                fputs("</body>\n</html>\n",fp_top3);
                fclose (fp_top3);
+               if (debugz) debugaz(_("No top users report because it is not configured in report_type\n"));
                return;
        }
 
diff --git a/util.c b/util.c
index b99fd6283bcf8657bf90ce148e18e1343ea7a343..f664f6c2b482b312bfb6d467bd1cba9349e704ce 100644 (file)
--- a/util.c
+++ b/util.c
@@ -448,6 +448,12 @@ void name_month(char *month,int month_len)
 }
 
 
+/*!
+Write a debug message to stderr. The message is prefixed by "SARG:" to identify its origin.
+
+\param msg The printf like message to format.
+\param ... The arguments to format in the message.
+*/
 void debuga(const char *msg,...)
 {
        va_list ap;
@@ -459,9 +465,20 @@ void debuga(const char *msg,...)
 }
 
 
-void debugaz(const char *head, const char *msg)
+/*!
+Write a debug message to stderr. The message is prefixed by "SARG: (info)".
+
+\param msg The printf like message to format.
+\param ... The arguments to format in the message.
+*/
+void debugaz(const char *msg,...)
 {
-       fprintf(stderr, "SARG: (util) %s=%s\n",head, msg);
+       va_list ap;
+
+       fputs(_("SARG: (info) "),stderr);
+       va_start(ap,msg);
+       vfprintf(stderr,msg,ap);
+       va_end(ap);
 }