From: Alan T. DeKok Date: Thu, 15 Nov 2012 18:51:21 +0000 (-0500) Subject: Log dates as UTC X-Git-Tag: release_2_2_1~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=463fd02402ec562145592a47a91393f14d507e92;p=thirdparty%2Ffreeradius-server.git Log dates as UTC --- diff --git a/src/main/log.c b/src/main/log.c index 51a53690af4..ec5665f191a 100644 --- a/src/main/log.c +++ b/src/main/log.c @@ -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), ": "); diff --git a/src/main/mainconfig.c b/src/main/mainconfig.c index d68c937182b..675118b937e 100644 --- a/src/main/mainconfig.c +++ b/src/main/mainconfig.c @@ -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 } };