]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Added "log { use_utc = yes/no }" configuration
authorAlan T. DeKok <aland@freeradius.org>
Thu, 8 Dec 2011 13:48:55 +0000 (14:48 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 8 Dec 2011 13:48:55 +0000 (14:48 +0100)
src/main/log.c
src/main/mainconfig.c

index 8bdd021f78e0ec1182085f69cec27dcef3379e57..51a53690af4ba37654f18f276701c8d8254eaa9f 100644 (file)
@@ -49,6 +49,9 @@ static const FR_NAME_NUMBER levels[] = {
        { NULL, 0 }
 };
 
+int log_dates_utc = 0;
+
+
 /*
  *     Log the message to the logfile. Include the severity and
  *     a time stamp.
@@ -280,7 +283,14 @@ void radlog_request(int lvl, int priority, REQUEST *request, const char *msg, ..
                time_t timeval;
                timeval = time(NULL);
 
-               CTIME_R(&timeval, buffer + len, sizeof(buffer) - len - 1);
+#ifdef HAVE_GMTIME_R
+               if (log_dates_utc) {
+                       struct tm utc;
+                       gmtime_r(&timeval, &utc);
+                       asctime_r(&utc, buffer + len);
+               } else
+#endif
+                       CTIME_R(&timeval, buffer + len, sizeof(buffer) - len - 1);
                
                s = strrchr(buffer, '\n');
                if (s) {
@@ -288,9 +298,7 @@ void radlog_request(int lvl, int priority, REQUEST *request, const char *msg, ..
                        s[1] = '\0';
                }
                
-               s = fr_int2str(levels, (lvl & ~L_CONS), ": ");
-               
-               strcat(buffer, s);
+               strcat(buffer, fr_int2str(levels, (lvl & ~L_CONS), ": "));
                len = strlen(buffer);
        }
        
index bd406c1ede635ba838ee177c5fd4adc4fe4d3302..4bd6142dc18523779c5fd3053c2ec411960e4ccc 100644 (file)
@@ -61,6 +61,7 @@ RCSID("$Id$")
 struct main_config_t mainconfig;
 char *request_log_file = NULL;
 char *debug_condition = NULL;
+extern int log_dates_utc;
 
 typedef struct cached_config_t {
        struct cached_config_t *next;
@@ -185,6 +186,7 @@ static const CONF_PARSER serverdest_config[] = {
        { "log", PW_TYPE_SUBSECTION, 0, NULL, (const void *) logdest_config },
        { "log_file", PW_TYPE_STRING_PTR, 0, &mainconfig.log_file, NULL },
        { "log_destination", PW_TYPE_STRING_PTR, 0, &radlog_dest, NULL },
+       { "use_utc", PW_TYPE_BOOLEAN, 0, &log_dates_utc, NULL },
        { NULL, -1, 0, NULL, NULL }
 };
 
@@ -198,6 +200,8 @@ static const CONF_PARSER log_config_nodest[] = {
        { "msg_badpass", PW_TYPE_STRING_PTR, 0, &mainconfig.auth_badpass_msg, NULL},
        { "msg_goodpass", PW_TYPE_STRING_PTR, 0, &mainconfig.auth_goodpass_msg, NULL},
 
+       { "use_utc", PW_TYPE_BOOLEAN, 0, &log_dates_utc, NULL },
+
        { NULL, -1, 0, NULL, NULL }
 };