Skip to content

Commit f57a8b5

Browse files
committed
Update mpprint.h
1 parent eb43c44 commit f57a8b5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

py/mpprint.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ 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-
8482
#if defined(MP_PRN_LEVEL) && (MP_PRN_LEVEL > 0)
8583
// Debug messages during code developing with MP_PRN(level, ...) & MP_PRN_LEVEL.
8684
// An approximate hierarchy of debug levels MP_PRN_LEVEL is:
@@ -102,7 +100,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
102100
if ((0 < level) && (level <= MP_PRN_LEVEL)) { \
103101
mp_printf(MP_PYTHON_PRINTER, " MP_PRN_LEVEL=%d : ", level); \
104102
mp_printf(MP_PYTHON_PRINTER, __VA_ARGS__); \
105-
mp_printf(MP_PYTHON_PRINTER, " : LINE=%d FILE=%s\n", __LINE__, __FILE__); \
103+
mp_printf(MP_PYTHON_PRINTER, " : FUNC=%s LINE=%d FILE=%s\n", __FUNCTION__, __LINE__, __FILE__); \
106104
} \
107105
} while (0);
108106
#else
@@ -113,19 +111,26 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
113111
// Set MP_PRN_LEVEL in developed *.C or *.CPP file, for example
114112
#define MP_PRN_LEVEL 1000 // show all messages
115113
// Add MP_PRN() macro in code, like
116-
void foo() {
117-
MP_PRN(6, "Enter foo()")
114+
void foo(int arg) {
115+
MP_PRN(MP_PRN_TRACE, "Enter foo()")
116+
if (arg < 0) {
117+
MP_PRN(MP_PRN_WARNING, "arg=%d less zero", arg)
118+
...
119+
}
118120
...
119121
int value;
120122
...
121123
// calculate value
122124
...
123-
MP_PRN(4, "See a value=%d", value)
125+
MP_PRN(MP_PRN_INFO, "See a value=%d", value)
124126
...
125-
MP_PRN(6, "Exit foo()")
127+
MP_PRN(MP_PRN_TRACE, "Exit foo()")
126128
}
129+
127130
// It is not a dogma. You may start debugging from level 3.
128131
#define MP_PRN_LEVEL 3
129132
// 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.
130133
// Then you may change MP_PRN_LEVEL to 2(reduce printing), and finally to 0(supress printing).
131134
*/
135+
136+
#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