From e401513552aad5b3b408747bc213ab3d69343363 Mon Sep 17 00:00:00 2001 From: Quantum Date: Thu, 14 Jan 2021 21:19:52 -0500 Subject: [PATCH] [host] windows: add timestamps to service logs This makes it easier to identify when things in the logs happened. --- host/platform/Windows/src/service.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/host/platform/Windows/src/service.c b/host/platform/Windows/src/service.c index c0d74ac5..2f6296e1 100644 --- a/host/platform/Windows/src/service.c +++ b/host/platform/Windows/src/service.c @@ -26,6 +26,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include +#include #include #include @@ -64,7 +65,16 @@ struct Service struct Service service = { 0 }; -void doLog(const char * fmt, ...) +char logTime[100]; + +char * currentTime() +{ + time_t t = time(NULL); + strftime(logTime, sizeof logTime, "%Y-%m-%d %H:%M:%S", localtime(&t)); + return logTime; +} + +void doLogReal(const char * fmt, ...) { va_list args; va_start(args, fmt); @@ -72,6 +82,8 @@ void doLog(const char * fmt, ...) va_end(args); } +#define doLog(fmt, ...) doLogReal("[%s] " fmt, currentTime(), ##__VA_ARGS__) + static bool setupAPI(void) { /* first look in kernel32.dll */