-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.h
More file actions
49 lines (41 loc) · 1.03 KB
/
Copy pathdebug.h
File metadata and controls
49 lines (41 loc) · 1.03 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include <stdio.h>
#define _GNU_SOURCE
#include <errno.h>
#ifndef LOG_EMERG
#define LOG_EMERG 0
#endif
#ifndef LOG_ALERT
#define LOG_ALERT 1
#endif
#ifndef LOG_CRIT
#define LOG_CRIT 2
#endif
#ifndef LOG_ERR
#define LOG_ERR 3
#endif
#ifndef LOG_WARNING
#define LOG_WARNING 4
#endif
#ifndef LOG_NOTICE
#define LOG_NOTICE 5
#endif
#ifndef LOG_INFO
#define LOG_INFO 6
#endif
#ifndef LOG_DEBUG
#define LOG_DEBUG 7
#endif
#ifndef DEFAULT_LOG_LEVEL
#define DEFAULT_LOG_LEVEL LOG_INFO
#endif
extern char *program_invocation_short_name;
#ifdef DEBUG
extern int log_level;
#define dbg( lvl, fmt, ... ) do { if (lvl <= log_level) fprintf( stderr, "%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__); } while (0)
#else
#define dbg( lvl, fmt, ... ) do { if (lvl == LOG_INFO || lvl <= LOG_ERR) fprintf( stderr, "%s: " fmt "\n", program_invocation_short_name, ##__VA_ARGS__); } while (0)
#endif /* DEBUG */
extern const char *errstr(int errnum);
#endif /* __DEBUG_H__ */