From: Alan T. DeKok Date: Sat, 30 Aug 2014 14:08:53 +0000 (-0400) Subject: Move suppression of debugging messages to a better place. Closes #772 X-Git-Tag: release_3_0_5~670 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37a7d95eac0f30f2dde412b7c3da0cb8d6a3bcda;p=thirdparty%2Ffreeradius-server.git Move suppression of debugging messages to a better place. Closes #772 vradlog() should always log. It's static to log.c, so the *callers* should take care to avoid calling vradlog(). The checks for debugging messages are pushed to radlog(), which is the external API. Added a static radlog_always(), which always calls vradlog(). It's just a wrapper to deal with the varargs stuff. The vradlog_request() function now calls radlog_always(), as vradlog_request() takes care of checking if debugging is enabled. --- diff --git a/src/main/log.c b/src/main/log.c index 0a784e90843..0f77ded8779 100644 --- a/src/main/log.c +++ b/src/main/log.c @@ -330,15 +330,6 @@ int vradlog(log_type_t type, char const *fmt, va_list ap) size_t len; int colourise = default_log.colourise; - /* - * NOT debugging, and trying to log debug messages. - * - * Throw the message away. - */ - if (!debug_flag && ((type & L_DBG) != 0)) { - return 0; - } - /* * If we don't want any messages, then * throw them away. @@ -481,6 +472,27 @@ int vradlog(log_type_t type, char const *fmt, va_list ap) } int radlog(log_type_t type, char const *msg, ...) +{ + va_list ap; + int r = 0; + + va_start(ap, msg); + + /* + * Non-debug message, or debugging is enabled. Log it. + */ + if (((type & L_DBG) == 0) || (debug_flag > 0)) { + r = vradlog(type, msg, ap); + } + va_end(ap); + + return r; +} + +/* + * Always log. + */ +static int CC_HINT(format (printf, 2, 3)) radlog_always(log_type_t type, char const *msg, ...) { va_list ap; int r; @@ -676,9 +688,9 @@ void vradlog_request(log_type_t type, log_debug_t lvl, REQUEST *request, char co indent = request->log.indent > sizeof(spaces) ? sizeof(spaces) : request->log.indent; - radlog(type, "(%u) %.*s%s%s", request->number, indent, spaces, extra, buffer); + radlog_always(type, "(%u) %.*s%s%s", request->number, indent, spaces, extra, buffer); } else { - radlog(type, "%s%s", extra, buffer); + radlog_always(type, "%s%s", extra, buffer); } } else { if (request) {