-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.h
22 lines (19 loc) · 785 Bytes
/
log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
#define LOG_FATAL (1)
#define LOG_ERR (2)
#define LOG_WARN (3)
#define LOG_INFO (4)
#define LOG_DEBUG (5)
#define LOG_TRACE (6)
#define LOG(level, type, ...) do { \
if (level <= debug_level) { \
printf("%s:%s:%d:", type, __FILE__, __LINE__); \
printf(__VA_ARGS__); \
printf("\n"); \
} \
} while (0)
#define debug_level LOG_DEBUG
#define trace(...) LOG(LOG_TRACE, "trace",__VA_ARGS__)
#define debug(...) LOG(LOG_DEBUG, "debug",__VA_ARGS__)
#define info(...) LOG(LOG_INFO, "info",__VA_ARGS__)
#define warn(...) LOG(LOG_WARN, "warn",__VA_ARGS__)