From 419f8b025f1f3f1c510895fdce53c26ab74cce5b Mon Sep 17 00:00:00 2001 From: zeffy Date: Fri, 30 Jun 2017 00:33:03 -0700 Subject: [PATCH] add datetime and process id to log entries --- wufuc/util.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wufuc/util.c b/wufuc/util.c index c88930e..82ca60b 100644 --- a/wufuc/util.c +++ b/wufuc/util.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -124,7 +125,6 @@ BOOL init_log(void) { if (!log_fp) { return FALSE; } - setvbuf(log_fp, NULL, _IONBF, 0); return TRUE; } @@ -136,9 +136,15 @@ VOID close_log(void) { VOID dwprintf_(LPCWSTR format, ...) { if (init_log()) { + WCHAR datebuf[9], timebuf[9]; + _wstrdate_s(datebuf, _countof(datebuf)); + _wstrtime_s(timebuf, _countof(timebuf)); + fwprintf_s(log_fp, L"%s %s [%d] ", datebuf, timebuf, GetCurrentProcessId()); + va_list argptr; va_start(argptr, format); vfwprintf_s(log_fp, format, argptr); va_end(argptr); + fflush(log_fp); } }