]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire: Pass all log messages to the context
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Oct 2023 15:06:51 +0000 (15:06 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Oct 2023 15:06:51 +0000 (15:06 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/pakfire.c

index b4d68963f0e2e968ca6d6590b30481868fa8507d..027674aed73c2478d6a598b36e91372782acc1f4 100644 (file)
@@ -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