diff --git a/daemon/logs.go b/daemon/logs.go index 6c9373f737..c16c7851fd 100644 --- a/daemon/logs.go +++ b/daemon/logs.go @@ -99,7 +99,8 @@ func (daemon *Daemon) ContainerLogs(job *engine.Job) engine.Status { } logLine := l.Log if times { - logLine = fmt.Sprintf("%s %s", l.Created.Format(format), logLine) + // format can be "" or time format, so here can't be error + logLine, _ = l.Format(format) } if l.Stream == "stdout" && stdout { io.WriteString(job.Stdout, logLine) diff --git a/pkg/jsonlog/jsonlog.go b/pkg/jsonlog/jsonlog.go index 3a96d86f82..e2c2a2cab6 100644 --- a/pkg/jsonlog/jsonlog.go +++ b/pkg/jsonlog/jsonlog.go @@ -23,7 +23,7 @@ func (jl *JSONLog) Format(format string) (string, error) { m, err := json.Marshal(jl) return string(m), err } - return fmt.Sprintf("[%s] %s", jl.Created.Format(format), jl.Log), nil + return fmt.Sprintf("%s %s", jl.Created.Format(format), jl.Log), nil } func (jl *JSONLog) Reset() { diff --git a/pkg/jsonlog/jsonlog_test.go b/pkg/jsonlog/jsonlog_test.go index 5ee5eda35c..fa53825b93 100644 --- a/pkg/jsonlog/jsonlog_test.go +++ b/pkg/jsonlog/jsonlog_test.go @@ -30,7 +30,8 @@ func TestWriteLog(t *testing.T) { if len(lines) != 30 { t.Fatalf("Must be 30 lines but got %d", len(lines)) } - logRe := regexp.MustCompile(`\[.*\] Line that thinks that it is log line from docker`) + // 30+ symbols, five more can come from system timezone + logRe := regexp.MustCompile(`.{30,} Line that thinks that it is log line from docker`) for _, l := range lines { if !logRe.MatchString(l) { t.Fatalf("Log line not in expected format: %q", l)