-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.cpp
47 lines (42 loc) · 918 Bytes
/
log.cpp
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
46
#include "ta-log.h"
int logD(const char* format, ...) {
va_list va;
int ret;
if (logLevel<LOGLEVEL_DEBUG) return 0;
printf("\x1b[1;34m[debug]\x1b[m ");
va_start(va,format);
ret=vprintf(format,va);
va_end(va);
fflush(stdout);
return ret;
}
int logI(const char* format, ...) {
va_list va;
int ret;
if (logLevel<LOGLEVEL_INFO) return 0;
printf("\x1b[1;32m[info]\x1b[m ");
va_start(va,format);
ret=vprintf(format,va);
va_end(va);
return ret;
}
int logW(const char* format, ...) {
va_list va;
int ret;
if (logLevel<LOGLEVEL_WARN) return 0;
printf("\x1b[1;33m[warning]\x1b[m ");
va_start(va,format);
ret=vprintf(format,va);
va_end(va);
return ret;
}
int logE(const char* format, ...) {
va_list va;
int ret;
if (logLevel<LOGLEVEL_ERROR) return 0;
printf("\x1b[1;31m[ERROR]\x1b[m ");
va_start(va,format);
ret=vprintf(format,va);
va_end(va);
return ret;
}