From 7dc64226aa8baf221f1d69f8187aae29b862b8f2 Mon Sep 17 00:00:00 2001 From: Christopher Wellons Date: Sun, 3 Feb 2019 16:01:24 -0500 Subject: [PATCH] Use RFC3339 dates in the log --- endlessh.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/endlessh.c b/endlessh.c index 8bf0b06..1c5e58e 100644 --- a/endlessh.c +++ b/endlessh.c @@ -47,8 +47,15 @@ static void logmsg(enum loglevel level, const char *format, ...) { if (loglevel >= level) { + /* Print a timestamp */ long long now = uepoch(); - printf("%lld.%03lld: ", now / 1000, now % 1000); + time_t t = now / 1000; + char date[64]; + struct tm tm[1]; + strftime(date, sizeof(date), "%Y-%m-%dT%H:%M:%S", gmtime_r(&t, tm)); + printf("%s.%03lldZ ", date, now % 1000); + + /* Print the rest of the log message */ va_list ap; va_start(ap, format); vprintf(format, ap);