diff --git a/logging.c b/logging.c index b57d257f35..dcb8e7638b 100644 --- a/logging.c +++ b/logging.c @@ -27,6 +27,12 @@ struct submit_data { int log_level; static struct submit_data sb; +bool is_printable_at_level(int level) +{ + return ((log_level >= level) && + (strcmp(nvme_cfg.output_format, "normal") == 0)); +} + int map_log_level(int verbose, bool quiet) { int log_level; diff --git a/logging.h b/logging.h index 57ab5906e1..2f4633c83b 100644 --- a/logging.h +++ b/logging.h @@ -5,16 +5,16 @@ #include -#define print_info(...) \ - do { \ - if (log_level >= LOG_INFO) \ - printf(__VA_ARGS__); \ +#define print_info(...) \ + do { \ + if (is_printable_at_level(LOG_INFO)) \ + printf(__VA_ARGS__); \ } while (false) -#define print_debug(...) \ - do { \ - if (log_level >= LOG_DEBUG) \ - printf(__VA_ARGS__); \ +#define print_debug(...) \ + do { \ + if (is_printable_at_level(LOG_DEBUG)) \ + printf(__VA_ARGS__); \ } while (false) extern int log_level; @@ -29,6 +29,7 @@ void nvme_submit_exit(struct nvme_transport_handle *hdl, bool nvme_decide_retry(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, int err); +bool is_printable_at_level(int level); int map_log_level(int verbose, bool quiet); #endif // DEBUG_H_