From: Uwe Hermann Date: Sat, 21 Apr 2018 22:23:10 +0000 (+0200) Subject: log: Move log level check so that it affects all handlers. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2c267f6819c2bd0e6f7101ffd4eec35ef6c2a734;p=libsigrok.git log: Move log level check so that it affects all handlers. Before this change, the loglevel check would only be performed for the default log handler in libsigrok, but not for other handlers set via sr_log_callback_set(). This fixes bug #698. --- diff --git a/src/log.c b/src/log.c index 55c5270f..caffa2a2 100644 --- a/src/log.c +++ b/src/log.c @@ -170,9 +170,7 @@ static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args /* This specific log callback doesn't need the void pointer data. */ (void)cb_data; - /* Only output messages of at least the selected loglevel(s). */ - if (loglevel > cur_loglevel) - return SR_OK; + (void)loglevel; if (cur_loglevel >= LOGLEVEL_TIMESTAMP) { elapsed_us = g_get_monotonic_time() - sr_log_start_time; @@ -217,6 +215,10 @@ SR_PRIV int sr_log(int loglevel, const char *format, ...) int ret; va_list args; + /* Only output messages of at least the selected loglevel(s). */ + if (loglevel > cur_loglevel) + return SR_OK; + va_start(args, format); ret = sr_log_cb(sr_log_cb_data, loglevel, format, args); va_end(args);