]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Log dates as UTC
authorAlan T. DeKok <aland@freeradius.org>
Thu, 15 Nov 2012 18:51:21 +0000 (13:51 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 15 Nov 2012 18:52:36 +0000 (13:52 -0500)
src/main/log.c
src/main/mainconfig.c

index 51a53690af4ba37654f18f276701c8d8254eaa9f..ec5665f191a39a15a6921ae2255d5d214b8e4d1f 100644 (file)
@@ -96,7 +96,14 @@ int vradlog(int lvl, const char *fmt, va_list ap)
                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 = fr_int2str(levels, (lvl & ~L_CONS), ": ");
 
index d68c937182b136cecc9214ccc5ebc3e612f9009a..675118b937edc726fbe5e6d2c5d1a43e29904c8e 100644 (file)
@@ -61,7 +61,10 @@ RCSID("$Id$")
 struct main_config_t mainconfig;
 char *request_log_file = NULL;
 char *debug_condition = NULL;
+
+#ifdef HAVE_GMTIME_R
 extern int log_dates_utc;
+#endif
 
 typedef struct cached_config_t {
        struct cached_config_t *next;
@@ -190,7 +193,9 @@ 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 },
+#ifdef HAVE_GMTIME_R
        { "use_utc", PW_TYPE_BOOLEAN, 0, &log_dates_utc, NULL },
+#endif
        { NULL, -1, 0, NULL, NULL }
 };
 
@@ -204,7 +209,9 @@ 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},
 
+#ifdef HAVE_GMTIME_R
        { "use_utc", PW_TYPE_BOOLEAN, 0, &log_dates_utc, NULL },
+#endif
 
        { NULL, -1, 0, NULL, NULL }
 };