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[]) {