From: Frederic Marchal Date: Wed, 4 Mar 2015 17:51:24 +0000 (+0100) Subject: First use of a debug level X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb59dc47e27549a4ae73f2c90c0caff4e113db8f;p=thirdparty%2Fsarg.git First use of a debug level Messages to be displayed at that level are those that used to be displayed by command line option -z. --- diff --git a/authfail.c b/authfail.c index 5717ac4..f14a0b1 100644 --- a/authfail.c +++ b/authfail.c @@ -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; } diff --git a/dansguardian_report.c b/dansguardian_report.c index 9a27599..a4fe8ee 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -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; } diff --git a/denied.c b/denied.c index d9247a8..587fdb3 100644 --- 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; } diff --git a/download.c b/download.c index e8f11bf..2b3b671 100644 --- a/download.c +++ b/download.c @@ -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; } diff --git a/getconf.c b/getconf.c index c0e22e5..ea253f9 100644 --- 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; diff --git a/grepday.c b/grepday.c index 302d8c8..e7bc8cd 100644 --- 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; } diff --git a/include/defs.h b/include/defs.h index aa4b4dd..d6253cd 100755 --- a/include/defs.h +++ b/include/defs.h @@ -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 diff --git a/ip2name.c b/ip2name.c index d38b048..2f82212 100644 --- 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 8e6468a..c34fe5c 100644 --- 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); } diff --git a/readlog.c b/readlog.c index f977a17..b306509 100644 --- 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; diff --git a/redirector.c b/redirector.c index a0678ee..7f29d8c 100644 --- a/redirector.c +++ b/redirector.c @@ -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")); } diff --git a/report.c b/report.c index 927ff38..5701528 100644 --- 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")); } diff --git a/siteuser.c b/siteuser.c index f3da9ef..3c584ca 100644 --- a/siteuser.c +++ b/siteuser.c @@ -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; } diff --git a/topsites.c b/topsites.c index 17ea529..d599744 100644 --- a/topsites.c +++ b/topsites.c @@ -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; } diff --git a/topuser.c b/topuser.c index c9c2164..8266cf5 100644 --- 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; }