X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcore%2Fplugin.c;h=b3d5973178dffed19411af5d5acea45a99b718e3;hb=033aa984a8b4be78ced113a3715422841a48d9a8;hp=8cd490a22a7da2f39e946f4d06be445fda1ebba7;hpb=32d934c91fc7d08f9d4ba0426366aeb202d7a468;p=sysdb.git 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 */