]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move radlog() and vradlog() to src/lib/log.c
authorAlan T. DeKok <aland@freeradius.org>
Tue, 17 Jan 2017 19:58:45 +0000 (14:58 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 17 Jan 2017 19:58:45 +0000 (14:58 -0500)
Along with default_log, and some other non-server logging things

src/include/fr_log.h
src/include/log.h
src/include/radiusd.h
src/lib/log.c
src/main/log.c

index 844cc1f79e4a1df104e57f6ebb9c588d16344034..3737739e69dd9b823b443ad157b0e7a361f78e83 100644 (file)
@@ -20,6 +20,8 @@
 #include <string.h>
 #include <stdbool.h>
 
+#include <freeradius-devel/token.h>
+
 /**
  * $Id$
  *
@@ -41,5 +43,75 @@ char const   *fr_syserror(int num);
 extern bool    fr_dns_lookups; /* do IP -> hostname lookups? */
 extern bool    fr_hostname_lookups; /* do hostname -> IP lookups? */
 extern int     fr_debug_lvl;   /* 0 = no debugging information */
+extern bool    log_dates_utc;
+
+extern const FR_NAME_NUMBER fr_log_levels[];
+
+typedef enum log_type {
+       L_AUTH = 2,                     //!< Authentication message.
+       L_INFO = 3,                     //!< Informational message.
+       L_ERR = 4,                      //!< Error message.
+       L_WARN = 5,                     //!< Warning.
+       L_PROXY = 6,                    //!< Proxy messages
+       L_ACCT = 7,                     //!< Accounting messages
+
+       L_DBG = 16,                     //!< Only displayed when debugging is enabled.
+       L_DBG_INFO = 17,                //!< Info only displayed when debugging is enabled.
+       L_DBG_WARN = 18,                //!< Warning only displayed when debugging is enabled.
+       L_DBG_ERR = 19,                 //!< Error only displayed when debugging is enabled.
+       L_DBG_WARN_REQ = 20,            //!< Less severe warning only displayed when debugging is enabled.
+       L_DBG_ERR_REQ = 21              //!< Less severe error only displayed when debugging is enabled.
+} log_type_t;
+
+typedef enum log_lvl {
+       L_DBG_LVL_DISABLE = -1,         //!< Don't print messages.
+       L_DBG_LVL_OFF = 0,              //!< No debug messages.
+       L_DBG_LVL_1,                    //!< Highest priority debug messages (-x).
+       L_DBG_LVL_2,                    //!< 2nd highest priority debug messages (-xx | -X).
+       L_DBG_LVL_3,                    //!< 3rd highest priority debug messages (-xxx | -Xx).
+       L_DBG_LVL_MAX                   //!< Lowest priority debug messages (-xxxx | -Xxx).
+} log_lvl_t;
+
+typedef enum log_dst {
+       L_DST_STDOUT = 0,               //!< Log to stdout.
+       L_DST_FILES,                    //!< Log to a file on disk.
+       L_DST_SYSLOG,                   //!< Log to syslog.
+       L_DST_STDERR,                   //!< Log to stderr.
+       L_DST_EXTRA,                    //!< Send log messages to a FILE*, via fopencookie()
+       L_DST_NULL,                     //!< Discard log messages.
+       L_DST_NUM_DEST
+} log_dst_t;
+
+typedef enum {
+       L_TIMESTAMP_AUTO = 0,           //!< Timestamp logging preference not specified. Do it based on
+                                       //!< debug level and destination.
+       L_TIMESTAMP_ON,                 //!< Always log timestamps.
+       L_TIMESTAMP_OFF                 //!< Never log timestamps.
+} log_timestamp_t;
+
+typedef struct fr_log_t {
+       log_dst_t       dst;            //!< Log destination.
+
+       bool            colourise;      //!< Prefix log messages with VT100 escape codes to change text
+                                       //!< colour.
+       log_timestamp_t timestamp;      //!< Prefix log messages with timestamps.
+
+       int             fd;             //!< File descriptor to write messages to.
+       char const      *file;          //!< Path to log file.
+
+       void            *cookie;        //!< for fopencookie()
+#ifdef HAVE_FOPENCOOKIE
+       ssize_t         (*cookie_write)(void *, char const *, size_t); //!< write function
+#else
+       int             (*cookie_write)(void *, char const *, int); //!< write function
+#endif
+} fr_log_t;
+
+extern fr_log_t default_log;
+
+int    vradlog(fr_log_t const *log, log_type_t lvl, char const *fmt, va_list ap)
+       CC_HINT(format (printf, 3, 0)) CC_HINT(nonnull (1,3));
+int    radlog(fr_log_t const *log, log_type_t lvl, char const *fmt, ...)
+       CC_HINT(format (printf, 3, 4)) CC_HINT(nonnull (1,3));
 
 #endif /* _FR_LOG_H */
index ffa0c6c5cd107a5855ae75e35e01aee74875a16b..985f218949a8bbfa45b911254664e26e77d42861 100644 (file)
  */
 RCSIDH(log_h, "$Id$")
 
+#include <freeradius-devel/fr_log.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef enum log_type {
-       L_AUTH = 2,                     //!< Authentication message.
-       L_INFO = 3,                     //!< Informational message.
-       L_ERR = 4,                      //!< Error message.
-       L_WARN = 5,                     //!< Warning.
-       L_PROXY = 6,                    //!< Proxy messages
-       L_ACCT = 7,                     //!< Accounting messages
-
-       L_DBG = 16,                     //!< Only displayed when debugging is enabled.
-       L_DBG_INFO = 17,                //!< Info only displayed when debugging is enabled.
-       L_DBG_WARN = 18,                //!< Warning only displayed when debugging is enabled.
-       L_DBG_ERR = 19,                 //!< Error only displayed when debugging is enabled.
-       L_DBG_WARN_REQ = 20,            //!< Less severe warning only displayed when debugging is enabled.
-       L_DBG_ERR_REQ = 21              //!< Less severe error only displayed when debugging is enabled.
-} log_type_t;
-
-typedef enum log_lvl {
-       L_DBG_LVL_DISABLE = -1,         //!< Don't print messages.
-       L_DBG_LVL_OFF = 0,              //!< No debug messages.
-       L_DBG_LVL_1,                    //!< Highest priority debug messages (-x).
-       L_DBG_LVL_2,                    //!< 2nd highest priority debug messages (-xx | -X).
-       L_DBG_LVL_3,                    //!< 3rd highest priority debug messages (-xxx | -Xx).
-       L_DBG_LVL_MAX                   //!< Lowest priority debug messages (-xxxx | -Xxx).
-} log_lvl_t;
-
-typedef enum log_dst {
-       L_DST_STDOUT = 0,               //!< Log to stdout.
-       L_DST_FILES,                    //!< Log to a file on disk.
-       L_DST_SYSLOG,                   //!< Log to syslog.
-       L_DST_STDERR,                   //!< Log to stderr.
-       L_DST_EXTRA,                    //!< Send log messages to a FILE*, via fopencookie()
-       L_DST_NULL,                     //!< Discard log messages.
-       L_DST_NUM_DEST
-} log_dst_t;
-
-typedef enum {
-       L_TIMESTAMP_AUTO = 0,           //!< Timestamp logging preference not specified. Do it based on
-                                       //!< debug level and destination.
-       L_TIMESTAMP_ON,                 //!< Always log timestamps.
-       L_TIMESTAMP_OFF                 //!< Never log timestamps.
-} log_timestamp_t;
-
-typedef struct fr_log_t {
-       log_dst_t       dst;            //!< Log destination.
-
-       bool            colourise;      //!< Prefix log messages with VT100 escape codes to change text
-                                       //!< colour.
-       log_timestamp_t timestamp;      //!< Prefix log messages with timestamps.
-
-       int             fd;             //!< File descriptor to write messages to.
-       char const      *file;          //!< Path to log file.
-
-       void            *cookie;        //!< for fopencookie()
-#ifdef HAVE_FOPENCOOKIE
-       ssize_t         (*cookie_write)(void *, char const *, size_t); //!< write function
-#else
-       int             (*cookie_write)(void *, char const *, int); //!< write function
-#endif
-} fr_log_t;
-
 typedef        void (*radlog_func_t)(log_type_t lvl, log_lvl_t priority, REQUEST *, char const *, va_list ap);
 
 extern FR_NAME_NUMBER const syslog_facility_table[];
 extern FR_NAME_NUMBER const syslog_severity_table[];
 extern FR_NAME_NUMBER const log_str2dst[];
-extern fr_log_t default_log;
 
 int    radlog_init(fr_log_t *log, bool daemonize);
 
-int    vradlog(fr_log_t const *log, log_type_t lvl, char const *fmt, va_list ap)
-       CC_HINT(format (printf, 3, 0)) CC_HINT(nonnull (1,3));
-int    radlog(fr_log_t const *log, log_type_t lvl, char const *fmt, ...)
-       CC_HINT(format (printf, 3, 4)) CC_HINT(nonnull (1,3));
-
 bool   debug_enabled(log_type_t type, log_lvl_t lvl);
 
 bool   rate_limit_enabled(void);
index d261535ef427cfd81c388ecf46fc8aa1014f13ab..454c691b3f3cc4f004200cc13eb981736d8c3dda 100644 (file)
@@ -593,7 +593,6 @@ int request_receive(TALLOC_CTX *ctx, rad_listen_t *listener, RADIUS_PACKET *pack
 
 /* main_config.c */
 /* Define a global config structure */
-extern bool                    log_dates_utc;
 extern main_config_t           main_config;
 extern bool                    event_loop_started;
 
index 22a1e564e92a5ad01aac639de02f290b3275c175..5cd57e32b4a055c09aa8db023ed478bc85e206ec 100644 (file)
@@ -32,6 +32,10 @@ RCSID("$Id$")
 #  include <features.h>
 #endif
 
+#ifdef HAVE_SYSLOG_H
+#  include <syslog.h>
+#endif
+
 #define FR_STRERROR_BUFSIZE (2048)
 
 fr_thread_local_setup(char *, fr_strerror_buffer)      /* macro */
@@ -397,3 +401,288 @@ void fr_canonicalize_error(TALLOC_CTX *ctx, char **sp, char **text, ssize_t slen
        *text = value;
 }
 
+/** Maps log categories to message prefixes
+ */
+const FR_NAME_NUMBER fr_log_levels[] = {
+       { "Debug : ",           L_DBG           },
+       { "Auth  : ",           L_AUTH          },
+       { "Proxy : ",           L_PROXY         },
+       { "Info  : ",           L_INFO          },
+       { "Warn  : ",           L_WARN          },
+       { "Acct  : ",           L_ACCT          },
+       { "Error : ",           L_ERR           },
+       { "WARN  : ",           L_DBG_WARN      },
+       { "ERROR : ",           L_DBG_ERR       },
+       { "WARN  : ",           L_DBG_WARN_REQ  },
+       { "ERROR : ",           L_DBG_ERR_REQ   },
+       { NULL, 0 }
+};
+
+/** @name VT100 escape sequences
+ *
+ * These sequences may be written to VT100 terminals to change the
+ * colour and style of the text.
+ *
+ @code{.c}
+   fprintf(stdout, VTC_RED "This text will be coloured red" VTC_RESET);
+ @endcode
+ * @{
+ */
+#define VTC_RED                "\x1b[31m"      //!< Colour following text red.
+#define VTC_YELLOW      "\x1b[33m"     //!< Colour following text yellow.
+#define VTC_BOLD       "\x1b[1m"       //!< Embolden following text.
+#define VTC_RESET      "\x1b[0m"       //!< Reset terminal text to default style/colour.
+/** @} */
+
+/** Maps log categories to VT100 style/colour escape sequences
+ */
+static const FR_NAME_NUMBER colours[] = {
+       { "",                   L_DBG           },
+       { VTC_BOLD,             L_AUTH          },
+       { VTC_BOLD,             L_PROXY         },
+       { VTC_BOLD,             L_INFO          },
+       { VTC_BOLD,             L_ACCT          },
+       { VTC_RED,              L_ERR           },
+       { VTC_BOLD VTC_YELLOW,  L_WARN          },
+       { VTC_BOLD VTC_RED,     L_DBG_ERR       },
+       { VTC_BOLD VTC_YELLOW,  L_DBG_WARN      },
+       { VTC_BOLD VTC_RED,     L_DBG_ERR_REQ   },
+       { VTC_BOLD VTC_YELLOW,  L_DBG_WARN_REQ  },
+       { NULL, 0 }
+};
+
+
+bool log_dates_utc = false;
+
+fr_log_t default_log = {
+       .colourise = false,             //!< Will be set later. Should be off before we do terminal detection.
+       .fd = STDOUT_FILENO,
+       .dst = L_DST_STDOUT,
+       .file = NULL,
+       .timestamp = L_TIMESTAMP_AUTO
+};
+
+/** Send a server log message to its destination
+ *
+ * @param log  destination.
+ * @param type of log message.
+ * @param msg  with printf style substitution tokens.
+ * @param ap   Substitution arguments.
+ */
+int vradlog(fr_log_t const *log, log_type_t type, char const *msg, va_list ap)
+{
+       uint8_t         *p;
+       char            buffer[10240];  /* The largest config item size, then extra for prefixes and suffixes */
+       char            *unsan;
+       size_t          len;
+       int             colourise = log->colourise;
+
+       /*
+        *      If we don't want any messages, then
+        *      throw them away.
+        */
+       if (log->dst == L_DST_NULL) return 0;
+
+       buffer[0] = '\0';
+       len = 0;
+
+       /*
+        *      Set colourisation
+        */
+       if (colourise) {
+               len += strlcpy(buffer + len, fr_int2str(colours, type, ""), sizeof(buffer) - len) ;
+               if (len == 0) {
+                       colourise = false;
+               }
+       }
+
+       /*
+        *      Mark the point where we treat the buffer as unsanitized.
+        */
+       unsan = buffer + len;
+
+       /*
+        *      Determine if we need to add a timestamp to the start of the message
+        */
+       switch (log->timestamp) {
+       case L_TIMESTAMP_OFF:
+               break;
+
+       /*
+        *      If we're not logging to syslog, and the debug level is -xxx
+        *      then log timestamps by default.
+        */
+       case L_TIMESTAMP_AUTO:
+               if (log->dst == L_DST_SYSLOG) break;
+               if ((log->dst != L_DST_FILES) && (fr_debug_lvl <= L_DBG_LVL_2)) break;
+               /* FALL-THROUGH */
+
+       case L_TIMESTAMP_ON:
+       {
+               time_t timeval;
+
+               timeval = time(NULL);
+#ifdef HAVE_GMTIME_R
+               if (log_dates_utc) {
+                       struct tm utc;
+                       gmtime_r(&timeval, &utc);
+                       ASCTIME_R(&utc, buffer + len, sizeof(buffer) - len - 1);
+               } else
+#endif
+               {
+                       CTIME_R(&timeval, buffer + len, sizeof(buffer) - len - 1);
+               }
+               len = strlen(buffer);
+               len += strlcpy(buffer + len, ": ", sizeof(buffer) - len - 1);
+       }
+               break;
+       }
+
+       /*
+        *      Add ERROR or WARNING prefixes to messages not going to
+        *      syslog.  It's redundant for syslog because of syslog
+        *      facilities.
+        */
+       if (log->dst != L_DST_SYSLOG) {
+               /*
+                *      Only print the 'facility' if we're not colourising the log messages
+                *      and this isn't syslog.
+                */
+               if (!log->colourise) {
+                       len += strlcpy(buffer + len, fr_int2str(fr_log_levels, type, ": "), sizeof(buffer) - len);
+               }
+
+               /*
+                *      Add an additional prefix to highlight that this is a bad message
+                *      the user should pay attention to.
+                */
+               if (len < sizeof(buffer)) switch (type) {
+               case L_DBG_WARN:
+                       len += strlcpy(buffer + len, "WARNING: ", sizeof(buffer) - len);
+                       break;
+
+               case L_DBG_ERR:
+                       len += strlcpy(buffer + len, "ERROR: ", sizeof(buffer) - len);
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       if (len < sizeof(buffer)) len += vsnprintf(buffer + len, sizeof(buffer) - len - 1, msg, ap);
+
+       /*
+        *      Filter out control chars and non UTF8 chars
+        */
+       for (p = (unsigned char *)unsan; *p != '\0'; p++) {
+               int clen;
+
+               switch (*p) {
+               case '\r':
+               case '\n':
+                       *p = ' ';
+                       break;
+
+               case '\t':
+                       continue;
+
+               default:
+                       clen = fr_utf8_char(p, -1);
+                       if (!clen) {
+                               *p = '?';
+                               continue;
+                       }
+                       p += (clen - 1);
+                       break;
+               }
+       }
+
+       /*
+        *      Reset colourisation if we applied it
+        */
+       if (colourise && (len < sizeof(buffer))) {
+               len += strlcpy(buffer + len, VTC_RESET, sizeof(buffer) - len);
+       }
+
+       if (len < (sizeof(buffer) - 2)) {
+               buffer[len]     = '\n';
+               buffer[len + 1] = '\0';
+       } else {
+               buffer[sizeof(buffer) - 2] = '\n';
+               buffer[sizeof(buffer) - 1] = '\0';
+       }
+
+       switch (log->dst) {
+
+#ifdef HAVE_SYSLOG_H
+       case L_DST_SYSLOG:
+               switch (type) {
+               case L_DBG:
+               case L_DBG_INFO:
+               case L_DBG_WARN:
+               case L_DBG_ERR:
+               case L_DBG_ERR_REQ:
+               case L_DBG_WARN_REQ:
+                       type = LOG_DEBUG;
+                       break;
+
+               case L_AUTH:
+               case L_PROXY:
+               case L_ACCT:
+                       type = LOG_NOTICE;
+                       break;
+
+               case L_INFO:
+                       type = LOG_INFO;
+                       break;
+
+               case L_WARN:
+                       type = LOG_WARNING;
+                       break;
+
+               case L_ERR:
+                       type = LOG_ERR;
+                       break;
+               }
+               syslog(type, "%s", buffer);
+               break;
+#endif
+
+       case L_DST_FILES:
+       case L_DST_STDOUT:
+       case L_DST_STDERR:
+               return write(log->fd, buffer, strlen(buffer));
+
+       default:
+       case L_DST_NULL:        /* should have been caught above */
+               break;
+       }
+
+       return 0;
+}
+
+/** Send a server log message to its destination
+ *
+ * @param log  destination.
+ * @param type of log message.
+ * @param msg  with printf style substitution tokens.
+ * @param ...  Substitution arguments.
+ */
+int radlog(fr_log_t const *log, 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) || (fr_debug_lvl > 0)) {
+               r = vradlog(log, type, msg, ap);
+       }
+       va_end(ap);
+
+       return r;
+}
index 95051803c62e027847ac5c2f0cf901c919852106..4b06d52dce64e4e8255d4a14e9e0eee588aadeb3 100644 (file)
@@ -47,56 +47,6 @@ log_lvl_t    rad_debug_lvl = 0;              //!< Global debugging level
 log_lvl_t      req_debug_lvl = 0;              //!< Request debugging level
 static bool    rate_limit = true;              //!< Whether repeated log entries should be rate limited
 
-/** Maps log categories to message prefixes
- */
-static const FR_NAME_NUMBER levels[] = {
-       { "Debug : ",           L_DBG           },
-       { "Auth  : ",           L_AUTH          },
-       { "Proxy : ",           L_PROXY         },
-       { "Info  : ",           L_INFO          },
-       { "Warn  : ",           L_WARN          },
-       { "Acct  : ",           L_ACCT          },
-       { "Error : ",           L_ERR           },
-       { "WARN  : ",           L_DBG_WARN      },
-       { "ERROR : ",           L_DBG_ERR       },
-       { "WARN  : ",           L_DBG_WARN_REQ  },
-       { "ERROR : ",           L_DBG_ERR_REQ   },
-       { NULL, 0 }
-};
-
-/** @name VT100 escape sequences
- *
- * These sequences may be written to VT100 terminals to change the
- * colour and style of the text.
- *
- @code{.c}
-   fprintf(stdout, VTC_RED "This text will be coloured red" VTC_RESET);
- @endcode
- * @{
- */
-#define VTC_RED                "\x1b[31m"      //!< Colour following text red.
-#define VTC_YELLOW      "\x1b[33m"     //!< Colour following text yellow.
-#define VTC_BOLD       "\x1b[1m"       //!< Embolden following text.
-#define VTC_RESET      "\x1b[0m"       //!< Reset terminal text to default style/colour.
-/** @} */
-
-/** Maps log categories to VT100 style/colour escape sequences
- */
-static const FR_NAME_NUMBER colours[] = {
-       { "",                   L_DBG           },
-       { VTC_BOLD,             L_AUTH          },
-       { VTC_BOLD,             L_PROXY         },
-       { VTC_BOLD,             L_INFO          },
-       { VTC_BOLD,             L_ACCT          },
-       { VTC_RED,              L_ERR           },
-       { VTC_BOLD VTC_YELLOW,  L_WARN          },
-       { VTC_BOLD VTC_RED,     L_DBG_ERR       },
-       { VTC_BOLD VTC_YELLOW,  L_DBG_WARN      },
-       { VTC_BOLD VTC_RED,     L_DBG_ERR_REQ   },
-       { VTC_BOLD VTC_YELLOW,  L_DBG_WARN_REQ  },
-       { NULL, 0 }
-};
-
 /** Syslog facility table
  *
  * Maps syslog facility keywords, to the syslog facility macros defined
@@ -209,16 +159,6 @@ const FR_NAME_NUMBER log_str2dst[] = {
        { NULL,                 L_DST_NUM_DEST  }
 };
 
-bool log_dates_utc = false;
-
-fr_log_t default_log = {
-       .colourise = false,             //!< Will be set later. Should be off before we do terminal detection.
-       .fd = STDOUT_FILENO,
-       .dst = L_DST_STDOUT,
-       .file = NULL,
-       .timestamp = L_TIMESTAMP_AUTO
-};
-
 static int stderr_fd = -1;             //!< The original unmolested stderr file descriptor
 static int stdout_fd = -1;             //!< The original unmolested stdout file descriptor
 
@@ -363,230 +303,6 @@ int radlog_init(fr_log_t *log, bool daemonize)
        return 0;
 }
 
-/** Send a server log message to its destination
- *
- * @param log  destination.
- * @param type of log message.
- * @param msg  with printf style substitution tokens.
- * @param ap   Substitution arguments.
- */
-int vradlog(fr_log_t const *log, log_type_t type, char const *msg, va_list ap)
-{
-       uint8_t         *p;
-       char            buffer[10240];  /* The largest config item size, then extra for prefixes and suffixes */
-       char            *unsan;
-       size_t          len;
-       int             colourise = log->colourise;
-
-       /*
-        *      If we don't want any messages, then
-        *      throw them away.
-        */
-       if (log->dst == L_DST_NULL) return 0;
-
-       buffer[0] = '\0';
-       len = 0;
-
-       /*
-        *      Set colourisation
-        */
-       if (colourise) {
-               len += strlcpy(buffer + len, fr_int2str(colours, type, ""), sizeof(buffer) - len) ;
-               if (len == 0) {
-                       colourise = false;
-               }
-       }
-
-       /*
-        *      Mark the point where we treat the buffer as unsanitized.
-        */
-       unsan = buffer + len;
-
-       /*
-        *      Determine if we need to add a timestamp to the start of the message
-        */
-       switch (log->timestamp) {
-       case L_TIMESTAMP_OFF:
-               break;
-
-       /*
-        *      If we're not logging to syslog, and the debug level is -xxx
-        *      then log timestamps by default.
-        */
-       case L_TIMESTAMP_AUTO:
-               if (log->dst == L_DST_SYSLOG) break;
-               if ((log->dst != L_DST_FILES) && (rad_debug_lvl <= L_DBG_LVL_2)) break;
-               /* FALL-THROUGH */
-
-       case L_TIMESTAMP_ON:
-       {
-               time_t timeval;
-
-               timeval = time(NULL);
-#ifdef HAVE_GMTIME_R
-               if (log_dates_utc) {
-                       struct tm utc;
-                       gmtime_r(&timeval, &utc);
-                       ASCTIME_R(&utc, buffer + len, sizeof(buffer) - len - 1);
-               } else
-#endif
-               {
-                       CTIME_R(&timeval, buffer + len, sizeof(buffer) - len - 1);
-               }
-               len = strlen(buffer);
-               len += strlcpy(buffer + len, ": ", sizeof(buffer) - len - 1);
-       }
-               break;
-       }
-
-       /*
-        *      Add ERROR or WARNING prefixes to messages not going to
-        *      syslog.  It's redundant for syslog because of syslog
-        *      facilities.
-        */
-       if (log->dst != L_DST_SYSLOG) {
-               /*
-                *      Only print the 'facility' if we're not colourising the log messages
-                *      and this isn't syslog.
-                */
-               if (!log->colourise) {
-                       len += strlcpy(buffer + len, fr_int2str(levels, type, ": "), sizeof(buffer) - len);
-               }
-
-               /*
-                *      Add an additional prefix to highlight that this is a bad message
-                *      the user should pay attention to.
-                */
-               if (len < sizeof(buffer)) switch (type) {
-               case L_DBG_WARN:
-                       len += strlcpy(buffer + len, "WARNING: ", sizeof(buffer) - len);
-                       break;
-
-               case L_DBG_ERR:
-                       len += strlcpy(buffer + len, "ERROR: ", sizeof(buffer) - len);
-                       break;
-
-               default:
-                       break;
-               }
-       }
-
-       if (len < sizeof(buffer)) len += vsnprintf(buffer + len, sizeof(buffer) - len - 1, msg, ap);
-
-       /*
-        *      Filter out control chars and non UTF8 chars
-        */
-       for (p = (unsigned char *)unsan; *p != '\0'; p++) {
-               int clen;
-
-               switch (*p) {
-               case '\r':
-               case '\n':
-                       *p = ' ';
-                       break;
-
-               case '\t':
-                       continue;
-
-               default:
-                       clen = fr_utf8_char(p, -1);
-                       if (!clen) {
-                               *p = '?';
-                               continue;
-                       }
-                       p += (clen - 1);
-                       break;
-               }
-       }
-
-       /*
-        *      Reset colourisation if we applied it
-        */
-       if (colourise && (len < sizeof(buffer))) {
-               len += strlcpy(buffer + len, VTC_RESET, sizeof(buffer) - len);
-       }
-
-       if (len < (sizeof(buffer) - 2)) {
-               buffer[len]     = '\n';
-               buffer[len + 1] = '\0';
-       } else {
-               buffer[sizeof(buffer) - 2] = '\n';
-               buffer[sizeof(buffer) - 1] = '\0';
-       }
-
-       switch (log->dst) {
-
-#ifdef HAVE_SYSLOG_H
-       case L_DST_SYSLOG:
-               switch (type) {
-               case L_DBG:
-               case L_DBG_INFO:
-               case L_DBG_WARN:
-               case L_DBG_ERR:
-               case L_DBG_ERR_REQ:
-               case L_DBG_WARN_REQ:
-                       type = LOG_DEBUG;
-                       break;
-
-               case L_AUTH:
-               case L_PROXY:
-               case L_ACCT:
-                       type = LOG_NOTICE;
-                       break;
-
-               case L_INFO:
-                       type = LOG_INFO;
-                       break;
-
-               case L_WARN:
-                       type = LOG_WARNING;
-                       break;
-
-               case L_ERR:
-                       type = LOG_ERR;
-                       break;
-               }
-               syslog(type, "%s", buffer);
-               break;
-#endif
-
-       case L_DST_FILES:
-       case L_DST_STDOUT:
-       case L_DST_STDERR:
-               return write(log->fd, buffer, strlen(buffer));
-
-       default:
-       case L_DST_NULL:        /* should have been caught above */
-               break;
-       }
-
-       return 0;
-}
-
-/** Send a server log message to its destination
- *
- * @param log  destination.
- * @param type of log message.
- * @param msg  with printf style substitution tokens.
- * @param ...  Substitution arguments.
- */
-int radlog(fr_log_t const *log, 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) || (rad_debug_lvl > 0)) {
-               r = vradlog(log, type, msg, ap);
-       }
-       va_end(ap);
-
-       return r;
-}
 
 /** Send a server log message to its destination without evaluating its debug level
  *
@@ -854,7 +570,7 @@ print_msg:
                fprintf(fp, "%s" "%s : " "%s" "%.*s" "%s" "%s" "\n",
                        msg_prefix,
                        time_buff,
-                       fr_int2str(levels, type, ""),
+                       fr_int2str(fr_log_levels, type, ""),
                        unlang_indent, spaces,
                        msg_module ? msg_module : "",
                        msg_exp);