@@ -79,8 +79,6 @@ 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
82
#if defined(MP_PRN_LEVEL ) && (MP_PRN_LEVEL > 0 )
85
83
// Debug messages during code developing with MP_PRN(level, ...) & MP_PRN_LEVEL.
86
84
// 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);
102
100
if ((0 < level) && (level <= MP_PRN_LEVEL)) { \
103
101
mp_printf(MP_PYTHON_PRINTER, " MP_PRN_LEVEL=%d : ", level); \
104
102
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__); \
106
104
} \
107
105
} while (0);
108
106
#else
@@ -113,19 +111,26 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
113
111
// Set MP_PRN_LEVEL in developed *.C or *.CPP file, for example
114
112
#define MP_PRN_LEVEL 1000 // show all messages
115
113
// 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
+ }
118
120
...
119
121
int value;
120
122
...
121
123
// calculate value
122
124
...
123
- MP_PRN(4 , "See a value=%d", value)
125
+ MP_PRN(MP_PRN_INFO , "See a value=%d", value)
124
126
...
125
- MP_PRN(6 , "Exit foo()")
127
+ MP_PRN(MP_PRN_TRACE , "Exit foo()")
126
128
}
129
+
127
130
// It is not a dogma. You may start debugging from level 3.
128
131
#define MP_PRN_LEVEL 3
129
132
// 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.
130
133
// Then you may change MP_PRN_LEVEL to 2(reduce printing), and finally to 0(supress printing).
131
134
*/
135
+
136
+ #endif // MICROPY_INCLUDED_PY_MPPRINT_H
0 commit comments