]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add timestamp option to log config
authorNick Porter <nick@portercomputing.co.uk>
Tue, 15 Jul 2025 16:03:47 +0000 (17:03 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Tue, 15 Jul 2025 16:03:47 +0000 (17:03 +0100)
So that timestamps can be added to debug logs at level 1 and 2 if
needed.

raddb/radiusd.conf.in
src/include/log.h
src/main/log.c
src/main/mainconfig.c

index 1bf4b8efcf1547839d114564dddd6c16903c4cc2..3fe562843d95acfd5f8227692ef195379c49ba7b 100644 (file)
@@ -461,6 +461,14 @@ log {
        #  by seeing what is actually being sent.
        #
 #      suppress_secrets = no
+
+       #  Add timestamps to debug logs
+       #
+       #  By default, at debug level 1 and 2, messages are produced
+       #  without timestamps.
+       #
+       #  Enabling this option will include timestamps on all debug logs.
+#      timestamp = no
 }
 
 #  The program to execute to do concurrency checks.
index 2736591779e3c80137b1a753bf75e5d2182595c5..f978496a0a32bcadd89f5465675a80058fb8f923 100644 (file)
@@ -70,6 +70,7 @@ typedef struct fr_log_t {
        log_dst_t       dst;            //!< Log destination.
        char const      *file;          //!< Path to log file.
        char const      *debug_file;    //!< Path to debug log file.
+       bool            timestamp;      //!< Should logs always have timestamps.
 } fr_log_t;
 
 typedef                void (*radlog_func_t)(log_type_t lvl, log_lvl_t priority, REQUEST *, char const *, va_list ap);
index 1ca2f914c258f3c199274421d7d2e2c96e747b18..cc31fdd0361868c7afdef53f97125426e861b3e3 100644 (file)
@@ -219,6 +219,7 @@ fr_log_t default_log = {
        .dst = L_DST_STDOUT,
        .file = NULL,
        .debug_file = NULL,
+       .timestamp = false,
 };
 
 static int stderr_fd = -1;     //!< The original unmolested stderr file descriptor
@@ -401,7 +402,7 @@ int vradlog(log_type_t type, char const *msg, va_list ap)
         *      of debugging.
         */
        if (default_log.dst != L_DST_SYSLOG) {
-               if ((rad_debug_lvl != 1) && (rad_debug_lvl != 2)) {
+               if (((rad_debug_lvl != 1) && (rad_debug_lvl != 2)) || default_log.timestamp) {
                        time_t timeval;
 
                        timeval = time(NULL);
index 147caaf323510b3dbfc52368cd98ca5f0d5556d9..4120392a91f072073ec9c98de1916c032281fbaf 100644 (file)
@@ -201,6 +201,7 @@ static const CONF_PARSER log_config[] = {
        { "use_utc", FR_CONF_POINTER(PW_TYPE_BOOLEAN, &log_dates_utc), NULL },
        { "msg_denied", FR_CONF_POINTER(PW_TYPE_STRING, &main_config.denied_msg), "You are already logged in - access denied" },
        { "suppress_secrets", FR_CONF_POINTER(PW_TYPE_BOOLEAN, &main_config.suppress_secrets), NULL },
+       { "timestamp", FR_CONF_POINTER(PW_TYPE_BOOLEAN, &default_log.timestamp), NULL },
        CONF_PARSER_TERMINATOR
 };