Skip to content

Commit

Permalink
Force logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Jan 15, 2025
1 parent c784f8a commit e87df74
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions include/zenoh-pico/utils/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -52,26 +55,26 @@ 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)

#define _Z_INFO(...) \
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)

#define _Z_ERROR(...) \
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)
Expand Down

0 comments on commit e87df74

Please sign in to comment.