]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move suppression of debugging messages to a better place. Closes #772
authorAlan T. DeKok <aland@freeradius.org>
Sat, 30 Aug 2014 14:08:53 +0000 (10:08 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 30 Aug 2014 14:08:53 +0000 (10:08 -0400)
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.

src/main/log.c

index 0a784e90843eb2aa4ec2aaaaebb93b5676769b48..0f77ded8779790952d89d6836abceee14a1e5d0d 100644 (file)
@@ -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) {