summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2019-03-03 21:13:49 -0500
committerMatthew Heon <mheon@redhat.com>2019-03-03 21:13:49 -0500
commite372837eb0dcafdf2fb5c3029ba340bbd9117fc3 (patch)
tree221fe5ea2f2af3ef203b6c5ca15cd0ad07ff2be8 /pkg
parent5afae0b25bba4e2274747b32cf8b3bc929daf06e (diff)
downloadpodman-e372837eb0dcafdf2fb5c3029ba340bbd9117fc3.tar.gz
podman-e372837eb0dcafdf2fb5c3029ba340bbd9117fc3.tar.bz2
podman-e372837eb0dcafdf2fb5c3029ba340bbd9117fc3.zip
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>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/logs/logs.go4
1 files changed, 4 insertions, 0 deletions
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 {