summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2018-04-22 00:17:49 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2018-04-22 00:17:49 +0200
commit5292279cbe4c228bbc31b8caf05eb6ebdfa29bde (patch)
treefeb9eeb2f351625b88e88c26e984db63d8ec851c
parent752086e9c8a0f7663f56a0a4ed65cc8f3591654b (diff)
downloadlibsigrokdecode-5292279cbe4c228bbc31b8caf05eb6ebdfa29bde.tar.gz
libsigrokdecode-5292279cbe4c228bbc31b8caf05eb6ebdfa29bde.zip
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 libsigrokdecode, but not for other handlers set via srd_log_callback_set(). This fixes bug #698.
-rw-r--r--log.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/log.c b/log.c
index a94bde7..459a5c1 100644
--- a/log.c
+++ b/log.c
@@ -156,9 +156,7 @@ static int srd_logv(void *cb_data, int loglevel, const char *format,
/* 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 SRD_OK;
+ (void)loglevel;
if (fputs("srd: ", stderr) < 0
|| g_vfprintf(stderr, format, args) < 0
@@ -176,6 +174,10 @@ SRD_PRIV int srd_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 SRD_OK;
+
va_start(args, format);
ret = srd_log_cb(srd_log_cb_data, loglevel, format, args);
va_end(args);