logs-show: fix corrupt output with empty messages
If a message had zero length, journalctl would print no newline, and
two output lines would be concatenated. Fix. The problem was
introduced in commit 31f7bf1994 ("logs-show: print multiline
messages"). Affected short and verbose output modes.
Before fix:
Feb 09 21:16:17 glyph dhclient[1323]: Feb 09 21:16:17 glyph NetworkManager[788]: <info> (enp4s2): DHCPv4 state changed nbi -> preinit
after:
Feb 09 21:16:17 glyph dhclient[1323]:
Feb 09 21:16:17 glyph NetworkManager[788]: <info> (enp4s2): DHCPv4 state changed nbi -> preinit
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
911f4d4d60
commit
47d80904a1
@@ -124,6 +124,11 @@ static bool print_multiline(FILE *f, unsigned prefix, unsigned n_columns, Output
|
||||
}
|
||||
}
|
||||
|
||||
/* A special case: make sure that we print a newline when
|
||||
the message is empty. */
|
||||
if (message_len == 0)
|
||||
fputs("\n", f);
|
||||
|
||||
for (pos = message;
|
||||
pos < message + message_len;
|
||||
pos = end + 1, line++) {
|
||||
|
||||
Reference in New Issue
Block a user