mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
vsh: use virBufferTrim in vshOutputLogFile
Use virBufferTrim to strip the extra newline at the end of the message instead of open-coding it after the buffer's string is formatted.
This commit is contained in:
parent
c7f0069e8b
commit
b4c6fa4418
@ -2110,6 +2110,7 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
|
|||||||
}
|
}
|
||||||
virBufferAsprintf(&buf, "%s ", lvl);
|
virBufferAsprintf(&buf, "%s ", lvl);
|
||||||
virBufferVasprintf(&buf, msg_format, ap);
|
virBufferVasprintf(&buf, msg_format, ap);
|
||||||
|
virBufferTrim(&buf, "\n", -1);
|
||||||
virBufferAddChar(&buf, '\n');
|
virBufferAddChar(&buf, '\n');
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
if (virBufferError(&buf))
|
||||||
@ -2117,10 +2118,6 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
|
|||||||
|
|
||||||
str = virBufferContentAndReset(&buf);
|
str = virBufferContentAndReset(&buf);
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
if (len > 1 && str[len - 2] == '\n') {
|
|
||||||
str[len - 1] = '\0';
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write log */
|
/* write log */
|
||||||
if (safewrite(ctl->log_fd, str, len) < 0)
|
if (safewrite(ctl->log_fd, str, len) < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user