mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-09-27 01:57:49 +00:00
Ensure that each log line is newline-terminated
When writing logs with timestamps to the terminal, ensure that each line is newline-terminated, so we don't end up with an unreadable mess with timestamps interspersed with the actual content being displayed. Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
parent
5afae0b25b
commit
e372837eb0
1 changed files with 4 additions and 0 deletions
|
|
@ -312,6 +312,10 @@ func (w *logWriter) write(msg *logMessage) error {
|
|||
if w.opts.Timestamps {
|
||||
prefix := append([]byte(msg.timestamp.Format(timeFormat)), delimiter[0])
|
||||
line = append(prefix, line...)
|
||||
// Ensure that lines always end in a newline
|
||||
if line[len(line)-1] != '\n' {
|
||||
line = append(line, '\n')
|
||||
}
|
||||
}
|
||||
// If the line is longer than the remaining bytes, cut it.
|
||||
if int64(len(line)) > w.remain {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue