mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[host] windows: add timestamps to service logs
This makes it easier to identify when things in the logs happened.
This commit is contained in:
parent
81561a242f
commit
e401513552
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user