@@ -80,15 +80,16 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
80
80
#endif
81
81
82
82
// Debug messages during code developing with MP_PRN(level, ...) & MP_PRN_LEVEL.
83
- // An approximate hierarchy of debug levels ( MP_PRN_LEVEL) is:
84
- // 0 - SUPPRES all messages. Use it in release version.
85
- // 1 - The most CRITICAL errors, often requiring a system reset, use message with this level if possible raising an exception.
83
+ // An approximate hierarchy of debug levels MP_PRN_LEVEL is:
84
+ // 0 - SUPPRESS all messages. Use it in the release version.
85
+ // 1 - For the most CRITICAL errors, often requiring a system reset. Use a message with this level, if possible, raising an exception.
86
86
// 2 - ERROR requiring program restart, use message with this level before raising an exception.
87
87
// 3 - WARNING, something went wrong, but you can fix it with additional operations in code right now or may ignore it.
88
88
// 4 - INFO, it is interesting and useful for understanding a bug.
89
- // 5 - DEBUG, more detaled info, dig deeper.
90
- // 6 - TRACE, show algorithm flow, like enter/exit a function.
91
- // In real you may use own classification of debug levels.
89
+ // 5 - DEBUG, more detailed information, dig deeper.
90
+ // 6 - TRACE, show a flow of the algorithm, like enter/exit a function.
91
+ // In reality, you may use your own classification of debug levels.
92
+ #if defined(MP_PRN_LEVEL ) && (MP_PRN_LEVEL > 0 )
92
93
#define MP_PRN (level , ...) \
93
94
do { \
94
95
if (MP_PRN_LEVEL > 0) { \
@@ -99,6 +100,9 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
99
100
} \
100
101
} \
101
102
} while (0);
103
+ #else
104
+ #define MP_PRN (level , ...)
105
+ #endif
102
106
/*
103
107
// How to use:
104
108
// Set MP_PRN_LEVEL in developed *.C or *.CPP file, for example
@@ -122,12 +126,6 @@ void foo() {
122
126
#define MP_PRN_LEVEL 3
123
127
// 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, ...)
124
128
// Then you may change MP_PRN_LEVEL to 2(reduce printing), and finally to 0(supress printing).
125
- //
126
- // To switching off MP_PRN() from a compiled binary, use
127
- #ifdef MP_PRN
128
- #undef MP_PRN
129
- #define MP_PRN(level, ...)
130
- #endif
131
129
*/
132
130
133
131
#endif // MICROPY_INCLUDED_PY_MPPRINT_H
0 commit comments