Browse Source

lib/utils/printf: Rework overriding printer of DEBUG_printf().

By default it uses mp_plat_print, but a port may override it to another
value with MICROPY_DEBUG_PRINTER_DEST.
pull/1800/merge
Paul Sokolovsky 9 years ago
parent
commit
47442d9f52
  1. 1
      esp8266/mpconfigport.h
  2. 11
      lib/utils/printf.c
  3. 4
      unix/mpconfigport.h

1
esp8266/mpconfigport.h

@ -9,6 +9,7 @@
#define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_MEM_STATS (0) #define MICROPY_MEM_STATS (0)
#define MICROPY_DEBUG_PRINTERS (1) #define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_DEBUG_PRINTER_DEST mp_debug_print
#define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_GC (1)
#define MICROPY_STACK_CHECK (1) #define MICROPY_STACK_CHECK (1)
#define MICROPY_REPL_EVENT_DRIVEN (0) #define MICROPY_REPL_EVENT_DRIVEN (0)

11
lib/utils/printf.c

@ -59,14 +59,11 @@ int vprintf(const char *fmt, va_list ap) {
int DEBUG_printf(const char *fmt, ...) { int DEBUG_printf(const char *fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
#if defined(MICROPY_DEBUG_STDERR) && MICROPY_DEBUG_STDERR #ifndef MICROPY_DEBUG_PRINTER_DEST
// Printing debug to stderr may give a chance tests which #define MICROPY_DEBUG_PRINTER_DEST mp_plat_print
// check stdout to pass, etc.
extern const mp_print_t mp_stderr_print;
int ret = mp_vprintf(&mp_stderr_print, fmt, ap);
#else
int ret = mp_vprintf(&mp_plat_print, fmt, ap);
#endif #endif
extern const mp_print_t MICROPY_DEBUG_PRINTER_DEST;
int ret = mp_vprintf(&MICROPY_DEBUG_PRINTER_DEST, fmt, ap);
va_end(ap); va_end(ap);
return ret; return ret;
} }

4
unix/mpconfigport.h

@ -51,7 +51,9 @@
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1) #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
#define MICROPY_MEM_STATS (1) #define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (1) #define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_DEBUG_STDERR (1) // Printing debug to stderr may give tests which
// check stdout a chance to pass, etc.
#define MICROPY_DEBUG_PRINTER_DEST mp_stderr_print
#define MICROPY_USE_READLINE_HISTORY (1) #define MICROPY_USE_READLINE_HISTORY (1)
#define MICROPY_HELPER_REPL (1) #define MICROPY_HELPER_REPL (1)
#define MICROPY_REPL_EMACS_KEYS (1) #define MICROPY_REPL_EMACS_KEYS (1)

Loading…
Cancel
Save