diff --git a/include/zenoh-pico/utils/logging.h b/include/zenoh-pico/utils/logging.h index a5ea4848b..4e65249a0 100644 --- a/include/zenoh-pico/utils/logging.h +++ b/include/zenoh-pico/utils/logging.h @@ -31,16 +31,19 @@ extern "C" { // Timestamp function static inline void __z_print_timestamp(void) { char ret[64]; - printf("[%s ", z_time_now_as_str(ret, sizeof(ret))); + fprintf(stderr, "[%s ", z_time_now_as_str(ret, sizeof(ret))); } // Logging macros #define _Z_LOG_PREFIX(prefix) \ __z_print_timestamp(); \ - printf(#prefix " ::%s] ", __func__); + fprintf(stderr, #prefix " ::%s] ", __func__); + +#undef ZENOH_DEBUG +#define ZENOH_DEBUG 3 // Ignore print only if log deactivated and build is release -#if ZENOH_DEBUG == 0 && !defined(Z_BUILD_DEBUG) +#if false // ZENOH_DEBUG == 0 && !defined(Z_BUILD_DEBUG) #define _Z_DEBUG(...) (void)(0) #define _Z_INFO(...) (void)(0) @@ -52,8 +55,8 @@ static inline void __z_print_timestamp(void) { do { \ if (ZENOH_DEBUG >= _Z_LOG_LVL_DEBUG) { \ _Z_LOG_PREFIX(DEBUG); \ - printf(__VA_ARGS__); \ - printf("\r\n"); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\r\n"); \ } \ } while (false) @@ -61,8 +64,8 @@ static inline void __z_print_timestamp(void) { do { \ if (ZENOH_DEBUG >= _Z_LOG_LVL_INFO) { \ _Z_LOG_PREFIX(INFO); \ - printf(__VA_ARGS__); \ - printf("\r\n"); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\r\n"); \ } \ } while (false) @@ -70,8 +73,8 @@ static inline void __z_print_timestamp(void) { do { \ if (ZENOH_DEBUG >= _Z_LOG_LVL_ERROR) { \ _Z_LOG_PREFIX(ERROR); \ - printf(__VA_ARGS__); \ - printf("\r\n"); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\r\n"); \ } \ } while (false) #endif // ZENOH_DEBUG == 0 && !defined(Z_BUILD_DEBUG)