From 703c09231bca96e2e5d680ead4b471ec9e276ef5 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 25 Jun 2014 23:12:44 +0200 Subject: [PATCH] plugin: Ignore internal loggers when checking for existing loggers. An internal logger may currently be registered by the frontend which uses it to send log messages to a client. Usually, these internal loggers will not actually log stuff. Thus, we'll have to ignore them when deciding about fallbacks. --- src/core/plugin.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/plugin.c b/src/core/plugin.c index 8cd490a..b3d5973 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -1113,12 +1113,11 @@ sdb_plugin_log(int prio, const char *msg) sdb_llist_iter_t *iter; int ret = -1; + _Bool logged = 0; + if (! msg) return 0; - if (! sdb_llist_len(log_list)) - return fprintf(stderr, "[%s] %s\n", SDB_LOG_PRIO_TO_STRING(prio), msg); - iter = sdb_llist_get_iter(log_list); while (sdb_llist_iter_has_next(iter)) { sdb_plugin_log_cb callback; @@ -1131,8 +1130,15 @@ sdb_plugin_log(int prio, const char *msg) tmp = callback(prio, msg, SDB_PLUGIN_CB(obj)->cb_user_data); if (tmp > ret) ret = tmp; + + if (SDB_PLUGIN_CB(obj)->cb_ctx) + logged = 1; + /* else: this is an internally registered callback */ } sdb_llist_iter_destroy(iter); + + if (! logged) + return fprintf(stderr, "[%s] %s\n", SDB_LOG_PRIO_TO_STRING(prio), msg); return ret; } /* sdb_plugin_log */ -- 2.30.2