From: Michael Tremer Date: Sun, 15 Oct 2023 15:15:03 +0000 (+0000) Subject: build: Send log messages to the context logger X-Git-Tag: 0.9.30~1497 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a555d2653313314ce3edd245d84135b641bde2f8;p=pakfire.git build: Send log messages to the context logger Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index da2848fd0..83c8dd531 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -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);