]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
First use of a debug level
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Wed, 4 Mar 2015 17:51:24 +0000 (18:51 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Wed, 4 Mar 2015 17:51:24 +0000 (18:51 +0100)
Messages to be displayed at that level are those that used to be displayed
by command line option -z.

15 files changed:
authfail.c
dansguardian_report.c
denied.c
download.c
getconf.c
grepday.c
include/defs.h
ip2name.c
log.c
readlog.c
redirector.c
report.c
siteuser.c
topsites.c
topuser.c

index 5717ac42efb3eb2a1ab1216cc4482c7812b1d36e..f14a0b1fa090bd4fd5b3299b269fc722f48b5578 100644 (file)
@@ -43,11 +43,11 @@ Open a file to store the authentication failure.
 void authfail_open(void)
 {
        if ((ReportType & REPORT_TYPE_AUTH_FAILURES) == 0) {
-               if (debugz) debugaz(_("Authentication failure report not produced as it is not requested\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Authentication failure report not produced as it is not requested\n"));
                return;
        }
        if (Privacy) {
-               if (debugz) debugaz(_("Authentication failure report not produced because privacy option is active\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Authentication failure report not produced because privacy option is active\n"));
                return;
        }
 
@@ -141,7 +141,7 @@ void authfail_report(void)
                        debuga(_("Failed to delete \"%s\": %s\n"),authfail_unsort,strerror(errno));
 
                authfail_unsort[0]='\0';
-               if (debugz) debugaz(_("Authentication failures report not produced because it is empty\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Authentication failures report not produced because it is empty\n"));
                return;
        }
 
index 9a275996302ac7a0cdb6afdb361e97eeb80a1e40..a4fe8eed9dc5d6912bbb3e25bbe20252a00ecde1 100644 (file)
@@ -62,7 +62,7 @@ void dansguardian_report(void)
        if(!dansguardian_count) {
                if (!KeepTempLog && unlink(dansguardian_in))
                        debuga(_("Cannot delete \"%s\": %s\n"),dansguardian_in,strerror(errno));
-               if (debugz) debugaz(_("Dansguardian report not generated because it is empty\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Dansguardian report not generated because it is empty\n"));
                return;
        }
 
index d9247a8bf609c8b3ab0b353bd92c7a9d96e85172..587fdb308ebdc3b5abcb213e6ab6386892dbb2db 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -43,11 +43,11 @@ Open a file to store the denied accesses.
 void denied_open(void)
 {
        if ((ReportType & REPORT_TYPE_DENIED) == 0) {
-               if (debugz) debugaz(_("Denied report not produced as it is not requested\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Denied report not produced as it is not requested\n"));
                return;
        }
        if (Privacy) {
-               if (debugz) debugaz(_("Denied report not produced because privacy option is active\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Denied report not produced because privacy option is active\n"));
                return;
        }
 
@@ -141,7 +141,7 @@ void gen_denied_report(void)
                if (!KeepTempLog && denied_unsort[0]!='\0' && unlink(denied_unsort))
                        debuga(_("Cannot delete \"%s\": %s\n"),denied_unsort,strerror(errno));
                denied_unsort[0]='\0';
-               if (debugz) debugaz(_("Denied report not produced because it is empty\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Denied report not produced because it is empty\n"));
                return;
        }
 
index e8f11bf52636966272fe4cc5558eae377f340a95..2b3b671472f2c250fa112c91149150a548ef0e1c 100644 (file)
@@ -61,11 +61,11 @@ Open a file to store the denied accesses.
 void download_open(void)
 {
        if ((ReportType & REPORT_TYPE_DOWNLOADS) == 0) {
-               if (debugz) debugaz(_("Download report not produced as it is not requested\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Download report not produced as it is not requested\n"));
                return;
        }
        if (Privacy) {
-               if (debugz) debugaz(_("Download report not produced because privacy option is active\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Download report not produced because privacy option is active\n"));
                return;
        }
 
@@ -188,7 +188,7 @@ void download_report(void)
                if (!KeepTempLog && download_unsort[0]!='\0' && unlink(download_unsort))
                        debuga(_("Cannot delete \"%s\": %s\n"),download_unsort,strerror(errno));
                download_unsort[0]='\0';
-               if (debugz) debugaz(_("No downloaded files to report\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("No downloaded files to report\n"));
                return;
        }
 
index c0e22e56ba7392e5fa81638bd9c1719f7e6eeef1..ea253f9336a336d79da8bfa42c1f369832c76078 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -585,7 +585,7 @@ static void parmtest(char *buf)
        if(*buf == '#' || *buf == '\0')
                return;
 
-       if(debugz)
+       if(debugz>=LogLevel_Process)
                printf(_("SARG: TAG: %s\n"),buf);
 
        if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return;
index 302d8c89c71f977369576a3c2ab010cc3fd87a56..e7bc8cd224f43b1bff829a104a027822cd83e076 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -632,12 +632,12 @@ void greport_prepare(void)
 {
 #ifdef HAVE_GD
        if (!Graphs) {
-               if (debugz)
+               if (debugz>=LogLevel_Process)
                        debugaz(_("Graphs disabled as requested in %s\n"),ConfigFile);
                return;
        }
        if (GraphFont[0]=='\0') {
-               if (debugz)
+               if (debugz>=LogLevel_Process)
                        debugaz(_("Graphs disabled as no font names were provided in %s\n"),ConfigFile);
                return;
        }
index aa4b4dd37e0fdfa40442cadf68f794dc3e0449e2..d6253cddeaf6795c6c028242ad2cc81bb951c9f7 100755 (executable)
@@ -6,6 +6,17 @@
 #define __attribute__(a)
 #endif
 
+//! \brief Constants to compare the log level to display messages
+enum DebugLogLevel
+{
+       //! Process informational messages.
+       LogLevel_Process=1,
+       //! Debug level messages.
+       LogLevel_Debug,
+       //! Display the source file name and line number along with the message.
+       LogLevel_Source
+};
+
 struct ReadLogStruct;//forward declaration
 
 struct getwordstruct
index d38b04836f9930c327a0d52d610f5eed72e25f18..2f822120af198915519ce9039f6a63fcfd677a79 100644 (file)
--- a/ip2name.c
+++ b/ip2name.c
@@ -186,7 +186,7 @@ void ip2name_forcedns(void)
                }
        }
        if (!DnsModule) {
-               if (debugz) debuga(_("No known module to resolve an IP address using the DNS\n"));
+               if (debugz>=LogLevel_Process) debuga(_("No known module to resolve an IP address using the DNS\n"));
                exit(EXIT_FAILURE);
        }
 
diff --git a/log.c b/log.c
index 8e6468af0ca49728b9cbe7ed154e252665436a9a..c34fe5cabba6a3144397a7f62ec035433134e047 100644 (file)
--- a/log.c
+++ b/log.c
@@ -615,7 +615,7 @@ int main(int argc,char *argv[])
                debuga(_("                            User (-u) = %s\n"),us);
                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(_("                Process messages (-z) = %d\n"),debugz);
                debuga(_(" Previous reports to keep (--lastlog) = %d\n"),LastLog);
                debuga("\n");
        }
@@ -651,7 +651,7 @@ int main(int argc,char *argv[])
                printf(_("                            User (-u) = %s\n"),us);
                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(_("                Process messages (-z) = %d\n"),debugz);
                printf(_(" Previous reports to keep (--lastlog) = %d\n"),LastLog);
                printf(_("sarg version: %s\n"),VERSION);
        }
index f977a17084431edb79b46e80ce15053a274ee12d..b306509787ef8127a37bd78faf73fc2ec7de6ec1 100644 (file)
--- a/readlog.c
+++ b/readlog.c
@@ -334,7 +334,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
                        }
                        current_format=LogFormats[x];
                        current_format_idx=x;
-                       if (debugz) {
+                       if (debugz>=LogLevel_Process) {
                                /* TRANSLATORS: The argument is the log format name as translated by you. */
                                debuga(_("Log format identified as \"%s\" for %s\n"),_(current_format->Name),arq);
                        }
@@ -414,7 +414,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
 
 
                if(strlen(log_entry.User) > MAX_USER_LEN) {
-                       if (debugm) printf(_("User ID too long: %s\n"),log_entry.User);
+                       if (debugz>=LogLevel_Process) debuga(_("User ID too long: %s\n"),log_entry.User);
                        excluded_count[ER_UserNameTooLong]++;
                        totregsx++;
                        continue;
@@ -430,7 +430,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
                }
 
                if(vercode(log_entry.HttpCode)) {
-                       if (debugm) printf(_("Excluded code: %s\n"),log_entry.HttpCode);
+                       if (debugz>=LogLevel_Process) debuga(_("Excluded code: %s\n"),log_entry.HttpCode);
                        excluded_count[ER_HttpCode]++;
                        totregsx++;
                        continue;
@@ -473,7 +473,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
                }
                if(Filter->HostFilter) {
                        if(!vhexclude(url)) {
-                               if (debugm) printf(_("Excluded site: %s\n"),url);
+                               if (debugz>=LogLevel_Process) debuga(_("Excluded site: %s\n"),url);
                                excluded_count[ER_Url]++;
                                totregsx++;
                                continue;
@@ -537,7 +537,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
 
                if(Filter->UserFilter) {
                        if(!vuexclude(log_entry.User)) {
-                               if (debugm) printf(_("Excluded user: %s\n"),log_entry.User);
+                               if (debugz>=LogLevel_Process) debuga(_("Excluded user: %s\n"),log_entry.User);
                                excluded_count[ER_IgnoredUser]++;
                                totregsx++;
                                continue;
index a0678ee2912bc5b1488f7111edfb358afe84477f..7f29d8ca1e5fde125a1dfd9c8acea028355745f9 100644 (file)
@@ -301,7 +301,7 @@ void redirector_log(void)
        str2 = user;
 
        if(SquidGuardConf[0] == '\0' && NRedirectorLogs == 0) {
-               if (debugz) debugaz(_("No redirector logs provided to produce that kind of report\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("No redirector logs provided to produce that kind of report\n"));
                return;
        }
 
@@ -449,7 +449,7 @@ void redirector_report(void)
        ouser2[0]='\0';
 
        if(!redirector_count) {
-               if (debugz) {
+               if (debugz>=LogLevel_Process) {
                        if (redirector_sorted[0])
                                debugaz(_("Redirector report not generated because it is empty\n"));
                }
index 927ff38eb56099c36f1fd2d334562766514d2a42..5701528e3e01e9ed6e176dd389577a603eb3dc80 100644 (file)
--- a/report.c
+++ b/report.c
@@ -96,7 +96,7 @@ void gerarel(void)
                exit(EXIT_FAILURE);
        }
 
-       if(debugz){
+       if(debugz>=LogLevel_Process){
                debugaz(_("outdirname=%s\n"),outdirname);
        }
 
@@ -371,7 +371,7 @@ void gerarel(void)
                if (!indexonly) {
                        if(DansGuardianConf[0] != '\0')
                                dansguardian_log();
-                       else if (debugz)
+                       else if (debugz>=LogLevel_Process)
                                debugaz(_("Dansguardian report not produced because no dansguardian configuration file was provided\n"));
 
                        redirector_log();
@@ -382,27 +382,27 @@ void gerarel(void)
                if (!indexonly) {
                        if((ReportType & REPORT_TYPE_DOWNLOADS) != 0)
                                download_report();
-                       else if (debugz)
+                       else if (debugz>=LogLevel_Process)
                                debugaz(_("Downloaded files report not requested in report_type\n"));
 
                        if((ReportType & REPORT_TYPE_TOPSITES) != 0)
                                topsites();
-                       else if (debugz)
+                       else if (debugz>=LogLevel_Process)
                                debugaz(_("Top sites report not requested in report_type\n"));
 
                        if((ReportType & REPORT_TYPE_SITES_USERS) != 0)
                                siteuser();
-                       else if (debugz)
+                       else if (debugz>=LogLevel_Process)
                                debugaz(_("Sites & users report not requested in report_type\n"));
 
                        if ((ReportType & REPORT_TYPE_DENIED) != 0)
                                gen_denied_report();
-                       else if (debugz)
+                       else if (debugz>=LogLevel_Process)
                                debugaz(_("Denied accesses report not requested in report_type\n"));
 
                        if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0)
                                authfail_report();
-                       else if (debugz)
+                       else if (debugz>=LogLevel_Process)
                                debugaz(_("Authentication failures report not requested in report_type\n"));
 
                        if(smartfilter) smartfilter_report();
@@ -414,7 +414,7 @@ void gerarel(void)
 
                        if((ReportType & REPORT_TYPE_USERS_SITES) != 0)
                                htmlrel();
-                       else if (debugz)
+                       else if (debugz>=LogLevel_Process)
                                debugaz(_("User's detailed report not requested in report_type\n"));
                }
 
index f3da9ef3acc6cbf99fb881d3c22faf59aa13843c..3c584ca5c87f5a58ccbbb5bd7228704c40fcec41 100644 (file)
@@ -49,7 +49,7 @@ void siteuser(void)
        struct userinfostruct *uinfo;
 
        if(Privacy) {
-               if (debugz) debugaz(_("Sites and users report not generated because privacy option is on\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Sites and users report not generated because privacy option is on\n"));
                return;
        }
 
index 17ea529339c3ed6bcb04084a60f155a492bfa3f5..d599744134a8b99b38aa45c7ac1b068434a2a32f 100644 (file)
@@ -69,7 +69,7 @@ void topsites(void)
        struct generalitemstruct item;
 
        if(Privacy) {
-               if (debugz) debugaz(_("Top sites report not produced because privacy option is on\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("Top sites report not produced because privacy option is on\n"));
                return;
        }
 
index c9c21646b35016bc1c8c0591a6bac94d34a2a8f4..8266cf5108234f0c7ebfec895fca2dd33f4b1de8 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -256,7 +256,7 @@ void topuser(void)
                        debuga(_("Write error in %s: %s\n"),top3,strerror(errno));
                        exit(EXIT_FAILURE);
                }
-               if (debugz) debugaz(_("No top users report because it is not configured in report_type\n"));
+               if (debugz>=LogLevel_Process) debugaz(_("No top users report because it is not configured in report_type\n"));
                return;
        }