Skip to content

Commit c62d2fa

Browse files
committed
Update mpprint.h
1 parent ebe4a1a commit c62d2fa

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

py/mpprint.h

100644100755
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ int mp_printf(const mp_print_t *print, const char *fmt, ...);
7979
int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
8080
#endif
8181

82+
#endif // MICROPY_INCLUDED_PY_MPPRINT_H
83+
84+
#if defined(MP_PRN_LEVEL) && (MP_PRN_LEVEL > 0)
8285
// Debug messages during code developing with MP_PRN(level, ...) & MP_PRN_LEVEL.
8386
// An approximate hierarchy of debug levels MP_PRN_LEVEL is:
8487
#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);
8992
#define MP_PRN_DEBUG 5 // DEBUG, more detailed information, dig deeper.
9093
#define MP_PRN_TRACE 6 // TRACE, show a flow of the algorithm, like enter/exit a function.
9194
// 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+
93100
#define MP_PRN(level, ...) \
94101
do { \
95102
if ((0 < level) && (level <= MP_PRN_LEVEL)) { \
96-
mp_printf(MP_PYTHON_PRINTER, " %d|| ", level); \
103+
mp_printf(MP_PYTHON_PRINTER, " %d || ", level); \
97104
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__); \
99106
} \
100107
} while (0);
101108
#else
@@ -119,7 +126,6 @@ void foo() {
119126
...
120127
MP_PRN(6, "Exit foo()")
121128
}
122-
123129
// It is not a dogma. You may start debugging from level 3.
124130
#define MP_PRN_LEVEL 3
125131
// 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() {
135141
#define DEBUG_printf(...)
136142
#endif
137143
#endif
138-
139-
#endif // MICROPY_INCLUDED_PY_MPPRINT_H

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy