line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "xh_config.h" |
2
|
|
|
|
|
|
|
#include "xh_core.h" |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#define XH_LOG_LEVEL XH_LOG_TRACE |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
static char *LOG_LEVEL_NAME[7] = { |
7
|
|
|
|
|
|
|
"CRITIC", |
8
|
|
|
|
|
|
|
"ERROR", |
9
|
|
|
|
|
|
|
"WARN", |
10
|
|
|
|
|
|
|
"NOTICE", |
11
|
|
|
|
|
|
|
"INFO", |
12
|
|
|
|
|
|
|
"DEBUG", |
13
|
|
|
|
|
|
|
"TRACE", |
14
|
|
|
|
|
|
|
}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
void |
17
|
0
|
|
|
|
|
|
xh_log(xh_log_level_t log_level, const char *func, xh_int_t line, const char *msg, ...) |
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
va_list args; |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
if (log_level > XH_LOG_LEVEL) return; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
(void) fprintf(stderr, "(%s) %s[%.0d]: ", LOG_LEVEL_NAME[log_level], func, (int) line); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
va_start(args, msg); |
26
|
0
|
|
|
|
|
|
(void) vfprintf(stderr, msg, args); |
27
|
0
|
0
|
|
|
|
|
if (msg[strlen(msg) - 1] != '\n') { |
28
|
0
|
|
|
|
|
|
(void) fprintf(stderr, "\n"); |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
va_end(args); |
31
|
|
|
|
|
|
|
} |