if (level < ctl->debug)
return;
- va_start(ap, format);
- vshOutputLogFile(ctl, level, format, ap);
- va_end(ap);
-
va_start(ap, format);
str = g_strdup_vprintf(format, ap);
va_end(ap);
+
+ vshOutputLogFile(ctl, level, str);
+
fputs(str, stdout);
fflush(stdout);
}
va_list ap;
g_autofree char *str = NULL;
- if (ctl != NULL) {
- va_start(ap, format);
- vshOutputLogFile(ctl, VSH_ERR_ERROR, format, ap);
- va_end(ap);
- }
+ va_start(ap, format);
+ str = g_strdup_vprintf(format, ap);
+ va_end(ap);
+
+ if (ctl)
+ vshOutputLogFile(ctl, VSH_ERR_ERROR, str);
/* Most output is to stdout, but if someone ran virsh 2>&1, then
* printing to stderr will not interleave correctly with stdout
fflush(stdout);
fputs(_("error: "), stderr);
- va_start(ap, format);
- str = g_strdup_vprintf(format, ap);
- va_end(ap);
-
fprintf(stderr, "%s\n", NULLSTR(str));
fflush(stderr);
}
* Outputting an error to log file.
*/
void
-vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
- va_list ap)
+vshOutputLogFile(vshControl *ctl, int log_level, const char *msg)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *str = NULL;
break;
}
virBufferAsprintf(&buf, "%s ", lvl);
- virBufferVasprintf(&buf, msg_format, ap);
+ virBufferAddStr(&buf, msg);
virBufferTrim(&buf, "\n");
virBufferAddChar(&buf, '\n');
void vshError(vshControl *ctl, const char *format, ...)
G_GNUC_PRINTF(2, 3);
void vshOpenLogFile(vshControl *ctl);
-void vshOutputLogFile(vshControl *ctl, int log_level, const char *format,
- va_list ap)
- G_GNUC_PRINTF(3, 0);
+void vshOutputLogFile(vshControl *ctl, int log_level, const char *msg);
void vshCloseLogFile(vshControl *ctl);
int vshCommandOptInt(vshControl *ctl, const vshCmd *cmd,