[host] windows: add timestamps to service logs

This makes it easier to identify when things in the logs happened.
This commit is contained in:
Quantum 2021-01-14 21:19:52 -05:00 committed by Geoffrey McRae
parent 81561a242f
commit e401513552

View File

@ -26,6 +26,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdarg.h>
#include <stdlib.h>
#include <inttypes.h>
#include <time.h>
#include <windows.h>
#include <winsvc.h>
@ -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 */