From: Michael Tremer Date: Tue, 19 Dec 2023 14:50:53 +0000 (+0000) Subject: jail: Forward function names of child processes X-Git-Tag: 0.9.30~1270 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f52ed2699f285310fe71f1742d2453c4e76629bd;p=pakfire.git jail: Forward function names of child processes Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/jail.c b/src/libpakfire/jail.c index 72341b3bc..23a40d88e 100644 --- a/src/libpakfire/jail.c +++ b/src/libpakfire/jail.c @@ -242,21 +242,12 @@ static void pakfire_jail_free(struct pakfire_jail* jail) { */ static int pakfire_jail_default_log_callback(struct pakfire* pakfire, void* data, int priority, const char* line, size_t length) { - switch (priority) { - case LOG_INFO: - INFO(pakfire, "%.*s", (int)length, line); - break; + struct pakfire_ctx* ctx = pakfire_ctx(pakfire); - case LOG_ERR: - ERROR(pakfire, "%.*s", (int)length, line); - break; + if (pakfire_ctx_get_log_level(ctx) >= priority) + pakfire_ctx_log(ctx, priority, NULL, 0, NULL, "%.*s", (int)length, line); -#ifdef ENABLE_DEBUG - case LOG_DEBUG: - DEBUG(pakfire, "%.*s", (int)length, line); - break; -#endif - } + pakfire_ctx_unref(ctx); return 0; } @@ -586,9 +577,16 @@ static void pakfire_jail_log_redirect(void* data, int priority, const char* file return; } + // End if we do not have a file descriptor to write to + if (fd < 0) + return; + + // Optionally log the function name + if (fn) + dprintf(fd, "%s: ", fn); + // Send the log message - if (fd >= 0) - vdprintf(fd, format, args); + vdprintf(fd, format, args); } static int pakfire_jail_log_buffer_is_full(const struct pakfire_log_buffer* buffer) {