From: Michael Tremer Date: Sat, 12 Oct 2024 12:26:48 +0000 (+0000) Subject: cli: build: Send all log messages to syslog, too X-Git-Tag: 0.9.30~1092 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bde60bc5e4e1b2ff5cd093df2e22574ab9d7c928;p=pakfire.git cli: build: Send all log messages to syslog, too Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/build.c b/src/cli/lib/build.c index f01a76be3..c3d23e1f4 100644 --- a/src/cli/lib/build.c +++ b/src/cli/lib/build.c @@ -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[]) {