forked from leverich/mutilate
-
Notifications
You must be signed in to change notification settings - Fork 9
/
log.h
25 lines (19 loc) · 777 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
23
24
25
#ifndef LOG_H
#define LOG_H
enum log_level_t { DEBUG, VERBOSE, INFO, WARN, QUIET };
extern log_level_t log_level;
void log_file_line(log_level_t level, const char *file, int line,
const char* format, ...);
#define L(level, args...) log_file_line(level, __FILE__, __LINE__, args)
#define D(args...) L(DEBUG, args)
#define V(args...) L(VERBOSE, args)
#define I(args...) L(INFO, args)
#define W(args...) L(WARN, args)
#define DIE(args...) do { W(args); exit(-1); } while (0)
#define NOLOG(x) \
do { log_level_t old = log_level; \
log_level = QUIET; \
(x); \
log_level = old; \
} while (0)
#endif // LOG_H