summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/logs/logs.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go
index fe4474f8b..1d920d691 100644
--- a/pkg/logs/logs.go
+++ b/pkg/logs/logs.go
@@ -277,10 +277,11 @@ func readLog(reader *bufio.Reader, opts *LogOptions) []string {
// logWriter controls the writing into the stream based on the log options.
type logWriter struct {
- stdout io.Writer
- stderr io.Writer
- opts *LogOptions
- remain int64
+ stdout io.Writer
+ stderr io.Writer
+ opts *LogOptions
+ remain int64
+ doAppend bool
}
// errMaximumWrite is returned when all bytes have been written.
@@ -309,14 +310,16 @@ func (w *logWriter) write(msg *logMessage) error {
return nil
}
line := msg.log
- if w.opts.Timestamps {
+ if w.opts.Timestamps && !w.doAppend {
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')
+ w.doAppend = true
}
}
+ if w.doAppend && line[len(line)-1] == '\n' {
+ w.doAppend = false
+ }
// If the line is longer than the remaining bytes, cut it.
if int64(len(line)) > w.remain {
line = line[:w.remain]