forked from bo3b/3Dmigoto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.h
46 lines (35 loc) · 1.24 KB
/
log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
using namespace std;
#include <string>
#include <ctime>
// Wrappers to make logging cleaner.
extern FILE *LogFile;
extern bool gLogDebug;
// Note that for now I've left the definitions of LogFile and LogDebug as they
// were - either declared locally in a file, as an extern, or from another
// namespace altogether. At some point this needs to be cleaned up, but it's
// probably not worth doing so unless we were switching to use a central
// logging framework.
#define LogInfo(fmt, ...) \
do { if (LogFile) fprintf(LogFile, fmt, __VA_ARGS__); } while (0)
#define vLogInfo(fmt, va_args) \
do { if (LogFile) vfprintf(LogFile, fmt, va_args); } while (0)
#define LogInfoW(fmt, ...) \
do { if (LogFile) fwprintf(LogFile, fmt, __VA_ARGS__); } while (0)
#define LogDebug(fmt, ...) \
do { if (gLogDebug) LogInfo(fmt, __VA_ARGS__); } while (0)
#define vLogDebug(fmt, va_args) \
do { if (gLogDebug) vLogInfo(fmt, va_args); } while (0)
#define LogDebugW(fmt, ...) \
do { if (gLogDebug) LogInfoW(fmt, __VA_ARGS__); } while (0)
static string LogTime()
{
string timeStr;
char cTime[32];
tm timestruct;
time_t ltime = time(0);
localtime_s(×truct, <ime);
asctime_s(cTime, sizeof(cTime), ×truct);
timeStr = cTime;
return timeStr;
}