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

index da2848fd074522bcedb9b49399925c6bce964df6..83c8dd531dcb72513bf042773a271a5664ceb995 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <pakfire/build.h>
 #include <pakfire/cgroup.h>
+#include <pakfire/ctx.h>
 #include <pakfire/dependencies.h>
 #include <pakfire/dist.h>
 #include <pakfire/file.h>
@@ -66,6 +67,7 @@ static const char* PAKFIRE_BUILD_PACKAGES[] = {
 };
 
 struct pakfire_build {
+       struct pakfire_ctx* ctx;
        struct pakfire* pakfire;
        int nrefs;
 
@@ -130,7 +132,7 @@ static int pakfire_build_log(struct pakfire_build* build, int priority, int erro
        int r;
 
        // Don't log messages of a lower loglevel
-       if (pakfire_log_get_priority(build->pakfire) < priority)
+       if (pakfire_ctx_get_log_level(build->ctx) < priority)
                return 0;
 
        // Format message
@@ -142,8 +144,8 @@ static int pakfire_build_log(struct pakfire_build* build, int priority, int erro
        if (r < 0)
                return r;
 
-       // Send everything to the parent logger
-       pakfire_log(build->pakfire, priority, error, file, line, function, "%s", buffer);
+       // Send everything to the context logger
+       pakfire_ctx_log(build->ctx, priority, file, line, function, "%s", buffer);
 
        // Call the build logger callback
        if (build->callbacks.log)
@@ -1368,7 +1370,10 @@ static void pakfire_build_free(struct pakfire_build* build) {
                pakfire_cgroup_unref(build->cgroup);
        }
 
-       pakfire_unref(build->pakfire);
+       if (build->pakfire)
+               pakfire_unref(build->pakfire);
+       if (build->ctx)
+               pakfire_ctx_unref(build->ctx);
        free(build);
 }
 
@@ -1631,6 +1636,9 @@ PAKFIRE_EXPORT int pakfire_build_create(struct pakfire_build** build,
        if (!b)
                return 1;
 
+       // Reference the context
+       b->ctx = pakfire_ctx(pakfire);
+
        // Reference pakfire
        b->pakfire = pakfire_ref(pakfire);