mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 06:11:46 +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
1 changed files with 13 additions and 1 deletions
|
@ -26,6 +26,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winsvc.h>
|
#include <winsvc.h>
|
||||||
|
@ -64,7 +65,16 @@ struct Service
|
||||||
|
|
||||||
struct Service service = { 0 };
|
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_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
@ -72,6 +82,8 @@ void doLog(const char * fmt, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define doLog(fmt, ...) doLogReal("[%s] " fmt, currentTime(), ##__VA_ARGS__)
|
||||||
|
|
||||||
static bool setupAPI(void)
|
static bool setupAPI(void)
|
||||||
{
|
{
|
||||||
/* first look in kernel32.dll */
|
/* first look in kernel32.dll */
|
||||||
|
|
Loading…
Reference in a new issue