diff options
Diffstat (limited to 'libmisc/include')
-rw-r--r-- | libmisc/include/libmisc/_intercept.h | 6 | ||||
-rw-r--r-- | libmisc/include/libmisc/log.h | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/libmisc/include/libmisc/_intercept.h b/libmisc/include/libmisc/_intercept.h index 87993e4..f9b7c8c 100644 --- a/libmisc/include/libmisc/_intercept.h +++ b/libmisc/include/libmisc/_intercept.h @@ -28,4 +28,10 @@ size_t __lm_printf(const char *format, ...); [[gnu::format(printf, 1, 2)]] size_t __lm_light_printf(const char *format, ...); +/* While newlib defines putchar() to be [[gnu::weak]], pico_stdio does + * not. Plus the above about optimizations. + */ + +void __lm_putchar(unsigned char c); + #endif /* _LIBMISC__INTERCEPT_H_ */ diff --git a/libmisc/include/libmisc/log.h b/libmisc/include/libmisc/log.h index 4529946..78ee1e7 100644 --- a/libmisc/include/libmisc/log.h +++ b/libmisc/include/libmisc/log.h @@ -10,6 +10,7 @@ #include <stdint.h> /* for uint8_t */ #include <libmisc/macro.h> +#include <libmisc/fmt.h> #include <libmisc/_intercept.h> #ifdef NDEBUG @@ -20,15 +21,25 @@ const char *const_byte_str(uint8_t b); +extern lo_interface fmt_dest _log_dest; + #define log_n_errorf(nam, fmt, ...) do { __lm_printf("error: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) #define log_n_infof(nam, fmt, ...) do { __lm_printf("info : " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) #define log_n_debugf(nam, fmt, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \ __lm_printf("debug: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) +#define log_n_errorln(nam, ...) fmt_print(_log_dest, "error: " LM_STR_(nam) ": ", __VA_ARGS__, "\n") +#define log_n_infoln(nam, ...) fmt_print(_log_dest, "info : " LM_STR_(nam) ": ", __VA_ARGS__, "\n") +#define log_n_debugln(nam, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \ + fmt_print(_log_dest, "debug: " LM_STR_(nam) ": ", __VA_ARGS__, "\n"); } while (0) + #endif /* _LIBMISC_LOG_H_ */ #if defined(LOG_NAME) && !defined(log_errorf) #define log_errorf(fmt, ...) log_n_errorf(LOG_NAME, fmt, __VA_ARGS__) #define log_infof(fmt, ...) log_n_infof(LOG_NAME, fmt, __VA_ARGS__) #define log_debugf(fmt, ...) log_n_debugf(LOG_NAME, fmt, __VA_ARGS__) +#define log_errorln(...) log_n_errorln(LOG_NAME, __VA_ARGS__) +#define log_infoln(...) log_n_infoln(LOG_NAME, __VA_ARGS__) +#define log_debugln(...) log_n_debugln(LOG_NAME, __VA_ARGS__) #endif |