-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.h
More file actions
58 lines (42 loc) · 1.5 KB
/
Copy pathdebug.h
File metadata and controls
58 lines (42 loc) · 1.5 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
#include "mbed.h"
#ifndef _DEBUG_H_
#define _DEBUG_H_
#include <cstdio>
#ifndef DEBUG_MODULE
#define DEBUG_MODULE __FILE__
#endif
namespace calsol {
namespace util {
namespace debugConsole {
extern char buffer[];
void puts(const char* string);
}
}}
#ifdef __GNUC__ // TODO should this be in its own file?
#define STRINGIFY(X) #X
#define TOSTRING(x) STRINGIFY(x)
#define COMPILERNAME "GNUC " TOSTRING(__GNUC__) "." TOSTRING(__GNUC_MINOR__) "." TOSTRING(__GNUC_PATCHLEVEL__)
#else
#error "Unknown compiler, add definition above"
#endif
#ifdef DEBUG_ENABLED
#define STRINGIFY(X) #X
#define TOSTRING(x) STRINGIFY(x)
#define debugPrint(f, ...) \
sprintf(calsol::util::debugConsole::buffer, f, ## __VA_ARGS__); \
calsol::util::debugConsole::puts(calsol::util::debugConsole::buffer); \
#define debugInfo(f, ...) \
calsol::util::debugConsole::puts("\033[36mInfo)\033[0m " DEBUG_MODULE " " TOSTRING(__LINE__) ": "); \
sprintf(calsol::util::debugConsole::buffer, f, ## __VA_ARGS__); \
calsol::util::debugConsole::puts(calsol::util::debugConsole::buffer); \
calsol::util::debugConsole::puts("\r\n");
#define debugWarn(f, ...) \
calsol::util::debugConsole::puts("\033[33mWarn)\033[0m " DEBUG_MODULE " " TOSTRING(__LINE__) ": "); \
sprintf(calsol::util::debugConsole::buffer, f, ## __VA_ARGS__); \
calsol::util::debugConsole::puts(calsol::util::debugConsole::buffer); \
calsol::util::debugConsole::puts("\r\n");
#else
#define debugInfo(f, ...) ;
#define debugWarn(f, ...) ;
#endif
#endif