]> git.ipfire.org Git - pakfire.git/commitdiff
cli: build: Send all log messages to syslog, too
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 12:26:48 +0000 (12:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 12:26:48 +0000 (12:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/build.c

index f01a76be35580c14199bbe8d26a9c6e76bbf00f6..c3d23e1f444b14e4c2499efa6ba259cff23a7801 100644 (file)
@@ -110,29 +110,27 @@ static void log_callback(void* data, int priority, const char* file, int line,
 
 static void log_callback(void* data, int priority, const char* file, int line,
                const char* function, const char* format, va_list args) {
-       char* buffer = NULL;
-       int r;
-
-       // Format the message
-       r = vasprintf(&buffer, format, args);
-       if (r < 0)
-               return;
+       va_list args_copy;
 
+       // Make a copy of args because we can only use them once...
+       va_copy(args_copy, args);
        switch (priority) {
-               // Highlight any error messages
-               case LOG_ERR:
-                       fprintf(stderr, "%s%s%s", color_highlight(), buffer, color_reset());
+               // Print messages to standard output
+               case LOG_INFO:
+                       vfprintf(stdout, format, args_copy);
                        break;
 
-               // Print the rest to stdout
-               default:
-                       fprintf(stdout, "%s", buffer);
+               // Highlight any error messages
+               case LOG_ERR:
+                       fputs(color_highlight(), stderr);
+                       vfprintf(stderr, format, args_copy);
+                       fputs(color_reset(), stderr);
                        break;
        }
+       va_end(args_copy);
 
-       // Cleanup
-       if (buffer)
-               free(buffer);
+       // Send everything to the default logger, too
+       pakfire_log_syslog(NULL, priority, file, line, function, format, args);
 }
 
 int cli_build(void* data, int argc, char* argv[]) {