]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
jail: Forward function names of child processes
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 Dec 2023 14:50:53 +0000 (14:50 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 Dec 2023 14:50:53 +0000 (14:50 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index 72341b3bcc9f7edccebf6b63c77190c412b9751b..23a40d88e4df48961a5eef4f61be31701fa12eac 100644 (file)
@@ -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) {