From e372837eb0dcafdf2fb5c3029ba340bbd9117fc3 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Sun, 3 Mar 2019 21:13:49 -0500 Subject: 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 --- pkg/logs/logs.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index b104c592b..fe4474f8b 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -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 { -- cgit v1.2.3-54-g00ecf