From 921f1a46bbccbdf9dcadbd7017ec0c575d2bed1f Mon Sep 17 00:00:00 2001 From: sanine Date: Thu, 23 Sep 2021 23:45:47 -0500 Subject: fix debug required logging level --- src/logging/logging.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/logging') diff --git a/src/logging/logging.h b/src/logging/logging.h index 4357ae1..8f4d174 100644 --- a/src/logging/logging.h +++ b/src/logging/logging.h @@ -5,7 +5,7 @@ struct honey_log_info { - enum { DEBUG, INFO, WARN, ERROR, FATAL } log_level; + enum { FATAL, ERROR, WARN, INFO, DEBUG } log_level; FILE *debug_out; FILE *info_out; FILE *warn_out; @@ -15,8 +15,14 @@ struct honey_log_info { const char * honey_log_level_str_(struct honey_log_info *info); -#define honey_debug_(info, ...) \ - fprintf(info.debug_out, "[DEBUG] " __VA_ARGS__) +#define honey_log_(info, required_level, prefix, ...) do { \ + if (info.log_level >= required_level) { \ + fprintf(info.debug_out, prefix " " __VA_ARGS__); \ + } \ + } while(0) + +#define honey_debug_(info, ...) \ + honey_log_(info, DEBUG, "[DEBUG]", __VA_ARGS__) #endif -- cgit v1.2.1