-
Notifications
You must be signed in to change notification settings - Fork 27
/
dbg.h
30 lines (23 loc) · 1.32 KB
/
dbg.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
#include <stdio.h>
#define ERR(fmt, args...) fprintf(stderr, fmt, ## args)
#define DBG2(fmt, args...) fprintf(stderr, "%s:%s:%-5d: " fmt, __FILE__, __FUNCTION__, __LINE__, ## args)
#define DBGE2(fmt, args...) fprintf(stderr, fmt, ## args)
#define ENTER2 do { fprintf(stderr, "%s:%s:%-5d: ENTER\n", __FILE__,__FUNCTION__, __LINE__); } while(0)
#define RET2(args...) do { fprintf(stderr, "%s:%s:%-5d: RETURN\n", __FILE__,__FUNCTION__, __LINE__);\
return args; } while(0)
enum { LOG_NONE, LOG_ERR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_ALL };
#ifdef DEBUGPRN
#define ENTER do { fprintf(stderr, "%s:%s:%-5d: ENTER\n", __FILE__,__FUNCTION__, __LINE__); } while(0)
#define RET(args...) do { fprintf(stderr, "%s:%s:%-5d: RETURN\n", __FILE__, __FUNCTION__, __LINE__);\
return args; } while(0)
#define DBG(fmt, args...) fprintf(stderr, "%s:%s:%-5d: " fmt, __FILE__,__FUNCTION__, __LINE__, ## args)
#define DBGE(fmt, args...) fprintf(stderr, fmt, ## args)
#define LOG(level, fmt, args...) fprintf(stderr, fmt, ## args)
#else
extern int log_level;
#define ENTER do { } while(0)
#define RET(args...) return args
#define DBG(fmt, args...) do { } while(0)
#define DBGE(fmt, args...) do { } while(0)
#define LOG(level, fmt, args...) do { if (level <= log_level) fprintf(stderr, fmt, ## args); } while(0)
#endif