@@ -79,6 +79,9 @@ int mp_printf(const mp_print_t *print, const char *fmt, ...);
79
79
int mp_vprintf (const mp_print_t * print , const char * fmt , va_list args );
80
80
#endif
81
81
82
+ #endif // MICROPY_INCLUDED_PY_MPPRINT_H
83
+
84
+ #if defined(MP_PRN_LEVEL ) && (MP_PRN_LEVEL > 0 )
82
85
// Debug messages during code developing with MP_PRN(level, ...) & MP_PRN_LEVEL.
83
86
// An approximate hierarchy of debug levels MP_PRN_LEVEL is:
84
87
#define MP_PRN_SUPPRESS 0 // SUPPRESS all messages. Use it in the release version.
@@ -89,13 +92,17 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
89
92
#define MP_PRN_DEBUG 5 // DEBUG, more detailed information, dig deeper.
90
93
#define MP_PRN_TRACE 6 // TRACE, show a flow of the algorithm, like enter/exit a function.
91
94
// In reality, you may use your own classification of debug levels.
92
- #if defined(MP_PRN_LEVEL ) && (MP_PRN_LEVEL > 0 )
95
+
96
+ #if defined(MP_PRN )
97
+ #undef MP_PRN
98
+ #endif
99
+
93
100
#define MP_PRN (level , ...) \
94
101
do { \
95
102
if ((0 < level) && (level <= MP_PRN_LEVEL)) { \
96
- mp_printf(MP_PYTHON_PRINTER, " %d|| ", level); \
103
+ mp_printf(MP_PYTHON_PRINTER, " %d || ", level); \
97
104
mp_printf(MP_PYTHON_PRINTER, __VA_ARGS__); \
98
- mp_printf(MP_PYTHON_PRINTER, " ||%d %s\n", __LINE__, __FILE__); \
105
+ mp_printf(MP_PYTHON_PRINTER, " || %d %s\n", __LINE__, __FILE__); \
99
106
} \
100
107
} while (0);
101
108
#else
@@ -119,7 +126,6 @@ void foo() {
119
126
...
120
127
MP_PRN(6, "Exit foo()")
121
128
}
122
-
123
129
// It is not a dogma. You may start debugging from level 3.
124
130
#define MP_PRN_LEVEL 3
125
131
// Then add MP_PRN(3, ...) and when gets too much messages then change some messages to the next level MP_PRN(4, ...), or MP_PRN(2, ...) etc.
@@ -135,5 +141,3 @@ void foo() {
135
141
#define DEBUG_printf (...)
136
142
#endif
137
143
#endif
138
-
139
- #endif // MICROPY_INCLUDED_PY_MPPRINT_H
0 commit comments