From: Michael Tremer Date: Sun, 15 Oct 2023 15:06:51 +0000 (+0000) Subject: pakfire: Pass all log messages to the context X-Git-Tag: 0.9.30~1499 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a2dbfebe2f681bfc8282054352c5940e6340e78;p=pakfire.git pakfire: Pass all log messages to the context Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index b4d68963f..027674aed 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -1682,26 +1682,29 @@ PAKFIRE_EXPORT void pakfire_set_log_callback(struct pakfire* pakfire, pakfire->callbacks.log_data = data; } +// XXX This function is deprecated and needs to be removed void pakfire_log(struct pakfire* pakfire, int priority, int r, const char* file, int line, const char* fn, const char* format, ...) { + char* buffer = NULL; va_list args; - // Do not do anything if callback isn't set - if (!pakfire->callbacks.log) - return; - // Save errno int saved_errno = errno; if (r) errno = r; va_start(args, format); - pakfire->callbacks.log(pakfire->callbacks.log_data, - priority, file, line, fn, format, args); + r = vasprintf(&buffer, format, args); va_end(args); // Restore errno errno = saved_errno; + + if (r < 0) + return; + + // Pass on to the context logger + pakfire_ctx_log(pakfire->ctx, priority, file, line, fn, "%s", buffer); } // UI