-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.h
34 lines (28 loc) · 1.03 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
#ifndef LOG_H
#define LOG_H
#include <cassert>
#include <cstdio>
extern bool verbose;
#define LOG(format, ...) do{ \
if (!verbose) break; \
printf(\
"%s:%d: " \
format "\n", \
__FUNCTION__, \
__LINE__, \
##__VA_ARGS__); \
}while(0)
#define ERR(format, ...) do{ \
printf(\
"%s:%d: " \
format "\n", \
__FUNCTION__, \
__LINE__, \
##__VA_ARGS__); \
}while(0)
#ifndef NDEBUG
#define ASSERT(X) assert(X)
#else
#define ASSERT(X) do{ if(X){}else{ERR("ASSERT failed: " #X); std::abort(); } }while(0)
#endif
#endif // LOG_H