mirror of
https://github.com/containers/podman.git
synced 2025-06-22 09:58:10 +08: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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user