blob: 6a97363c4db29ceae584ae764cbbdb04a61bcb53 [file] [log] [blame] [edit]
diff -aruN a/sysklogd/syslogd.c c/sysklogd/syslogd.c
--- a/sysklogd/syslogd.c 2011-10-29 04:43:01.000000000 -0700
+++ c/sysklogd/syslogd.c 2012-01-04 10:11:05.921879376 -0800
@@ -24,6 +24,7 @@
//usage: "\n -O FILE Log to FILE (default:/var/log/messages)"
//usage: "\n -l N Log only messages more urgent than prio N (1-8)"
//usage: "\n -S Smaller output"
+//usage: "\n -u Log time stamps in Coordinated Universal Time (UTC)"
//usage: IF_FEATURE_ROTATE_LOGFILE(
//usage: "\n -s SIZE Max size (KB) before rotation (default:200KB, 0=off)"
//usage: "\n -b N N rotated logs to keep (default:1, max=99, 0=purge)"
@@ -205,6 +206,7 @@
OPTBIT_outfile, // -O
OPTBIT_loglevel, // -l
OPTBIT_small, // -S
+ OPTBIT_utc, // -u
IF_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize ,) // -s
IF_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt ,) // -b
IF_FEATURE_REMOTE_LOG( OPTBIT_remotelog ,) // -R
@@ -218,6 +220,7 @@
OPT_outfile = 1 << OPTBIT_outfile ,
OPT_loglevel = 1 << OPTBIT_loglevel,
OPT_small = 1 << OPTBIT_small ,
+ OPT_utc = 1 << OPTBIT_utc ,
OPT_filesize = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize )) + 0,
OPT_rotatecnt = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt )) + 0,
OPT_remotelog = IF_FEATURE_REMOTE_LOG( (1 << OPTBIT_remotelog )) + 0,
@@ -226,7 +229,7 @@
OPT_dup = IF_FEATURE_SYSLOGD_DUP( (1 << OPTBIT_dup )) + 0,
OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0,
};
-#define OPTION_STR "m:nO:l:S" \
+#define OPTION_STR "m:nO:l:Su" \
IF_FEATURE_ROTATE_LOGFILE("s:" ) \
IF_FEATURE_ROTATE_LOGFILE("b:" ) \
IF_FEATURE_REMOTE_LOG( "R:" ) \
@@ -649,10 +652,30 @@
|| msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
) {
time(&now);
- timestamp = ctime(&now) + 4; /* skip day of week */
+ if (option_mask32 & OPT_utc)
+ timestamp = asctime(gmtime(&now));
+ else
+ timestamp = asctime(localtime(&now));
+ timestamp += 4; /* skip day of week */
} else {
- now = 0;
- timestamp = msg;
+ if (option_mask32 & OPT_utc) {
+ struct tm parsed, local;
+ now = time(NULL);
+ localtime_r(&now, &local);
+ if (strptime(msg, "%h %e %T", &parsed) != NULL) {
+ parsed.tm_gmtoff = local.tm_gmtoff;
+ parsed.tm_zone = local.tm_zone;
+ parsed.tm_year = local.tm_year;
+ parsed.tm_isdst = local.tm_isdst;
+ now = mktime(&parsed);
+ timestamp = asctime(gmtime(&now)) + 4;
+ } else {
+ timestamp = msg;
+ }
+ } else {
+ now = 0;
+ timestamp = msg;
+ }
msg += 16;
}
timestamp[15] = '\0';