-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug.h
More file actions
61 lines (51 loc) · 1.48 KB
/
debug.h
File metadata and controls
61 lines (51 loc) · 1.48 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
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include "xformat.h"
#define LOG_ERROR 10
#define LOG_WARN 20
#define LOG_INFO 30
#define LOG_DEBUG 40
#define LOG_TRACE 50
#if LOG_LEVEL >= LOG_TRACE
#define trace(fmt, ...) message("[T] " fmt, ##__VA_ARGS__)
#define UNUSED_TRACE
#else
#define trace(...)
#define UNUSED_TRACE __attribute__((__unused__))
#endif
#if LOG_LEVEL >= LOG_DEBUG
#define debug(fmt, ...) message("[D] " fmt, ##__VA_ARGS__)
#define UNUSED_DEBUG
#else
#define debug(...)
#define UNUSED_DEBUG __attribute__((__unused__))
#endif
#if LOG_LEVEL >= LOG_INFO
#define info(fmt, ...) message("[I] " fmt, ##__VA_ARGS__)
#define UNUSED_INFO
#else
#define info(...)
#define UNUSED_INFO __attribute__((__unused__))
#endif
#if LOG_LEVEL >= LOG_WARNING
#define warning(fmt, ...) message("[W] " fmt, ##__VA_ARGS__)
#define UNUSED_WARNING
#else
#define warning(...)
#define UNUSED_WARNING __attribute__((__unused__))
#endif
#if LOG_LEVEL >= LOG_ERROR
#define error(fmt, ...) message("[E] " fmt, ##__VA_ARGS__)
#define UNUSED_ERROR
#else
#define error(...)
#define UNUSED_ERROR __attribute__((__unused__))
#endif
#define fatal(fmt, ...) \
{ \
message("[F] " fmt "restarting...\r\n", ##__VA_ARGS__); \
mdelay(100); \
reset(); \
}
void __attribute__((format(printf, 1, 2))) message(const char *fmt, ...);
#endif