From: Alan T. DeKok Date: Thu, 8 Dec 2011 13:48:55 +0000 (+0100) Subject: Added "log { use_utc = yes/no }" configuration X-Git-Tag: release_3_0_0_beta0~447 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ae6b94c9b87dd35192360e5acfea283d804ad8b;p=thirdparty%2Ffreeradius-server.git Added "log { use_utc = yes/no }" configuration --- diff --git a/src/main/log.c b/src/main/log.c index cf8994b7431..6a20fd944a9 100644 --- a/src/main/log.c +++ b/src/main/log.c @@ -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); } diff --git a/src/main/mainconfig.c b/src/main/mainconfig.c index d6986b2bd31..73a82019545 100644 --- a/src/main/mainconfig.c +++ b/src/main/mainconfig.c @@ -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 } };