From b0b84165b4bc2073761afb37138ff11589327318 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Wed, 28 Jan 2015 14:33:15 -0800 Subject: [PATCH 1/2] Fix logs, so now, old and followed logs has same format without [] Signed-off-by: Alexander Morozov Upstream-commit: e16bcc3928d0ae07cb9c02840fbb92f1ed2a7a3f Component: engine --- components/engine/daemon/logs.go | 3 ++- components/engine/pkg/jsonlog/jsonlog.go | 2 +- components/engine/pkg/jsonlog/jsonlog_test.go | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/engine/daemon/logs.go b/components/engine/daemon/logs.go index 6c9373f737..c16c7851fd 100644 --- a/components/engine/daemon/logs.go +++ b/components/engine/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/components/engine/pkg/jsonlog/jsonlog.go b/components/engine/pkg/jsonlog/jsonlog.go index 3a96d86f82..e2c2a2cab6 100644 --- a/components/engine/pkg/jsonlog/jsonlog.go +++ b/components/engine/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/components/engine/pkg/jsonlog/jsonlog_test.go b/components/engine/pkg/jsonlog/jsonlog_test.go index 5ee5eda35c..fa53825b93 100644 --- a/components/engine/pkg/jsonlog/jsonlog_test.go +++ b/components/engine/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) From e7165e9c1db868f2fb5bab48f67f9e227d10b252 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Wed, 28 Jan 2015 20:53:53 -0800 Subject: [PATCH 2/2] Update events format in man page Signed-off-by: Alexandr Morozov Upstream-commit: f750f17451f7e36367c49f2e45c9fcc261a000cc Component: engine --- components/engine/docs/man/docker-events.1.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/components/engine/docs/man/docker-events.1.md b/components/engine/docs/man/docker-events.1.md index d869498c94..bff04a6d15 100644 --- a/components/engine/docs/man/docker-events.1.md +++ b/components/engine/docs/man/docker-events.1.md @@ -45,23 +45,23 @@ After running docker events a container 786d698004576 is started and stopped (The container name has been shortened in the output below): # docker events - [2014-04-12 18:23:04 -0400 EDT] 786d69800457: (from whenry/testimage:latest) start - [2014-04-12 18:23:13 -0400 EDT] 786d69800457: (from whenry/testimage:latest) die - [2014-04-12 18:23:13 -0400 EDT] 786d69800457: (from whenry/testimage:latest) stop + 2015-01-28T20:21:31.000000000-08:00 59211849bc10: (from whenry/testimage:latest) start + 2015-01-28T20:21:31.000000000-08:00 59211849bc10: (from whenry/testimage:latest) die + 2015-01-28T20:21:32.000000000-08:00 59211849bc10: (from whenry/testimage:latest) stop ## Listening for events since a given date Again the output container IDs have been shortened for the purposes of this document: - # docker events --since '2014-04-12' - [2014-04-12 18:11:28 -0400 EDT] c655dbf640dc: (from whenry/testimage:latest) create - [2014-04-12 18:11:28 -0400 EDT] c655dbf640dc: (from whenry/testimage:latest) start - [2014-04-12 18:14:13 -0400 EDT] 786d69800457: (from whenry/testimage:latest) create - [2014-04-12 18:14:13 -0400 EDT] 786d69800457: (from whenry/testimage:latest) start - [2014-04-12 18:22:44 -0400 EDT] 786d69800457: (from whenry/testimage:latest) die - [2014-04-12 18:22:44 -0400 EDT] 786d69800457: (from whenry/testimage:latest) stop - [2014-04-12 18:23:04 -0400 EDT] 786d69800457: (from whenry/testimage:latest) start - [2014-04-12 18:23:13 -0400 EDT] 786d69800457: (from whenry/testimage:latest) die - [2014-04-12 18:23:13 -0400 EDT] 786d69800457: (from whenry/testimage:latest) stop + # docker events --since '2015-01-28' + 2015-01-28T20:25:38.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) create + 2015-01-28T20:25:38.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) start + 2015-01-28T20:25:39.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) create + 2015-01-28T20:25:39.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) start + 2015-01-28T20:25:40.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) die + 2015-01-28T20:25:42.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) stop + 2015-01-28T20:25:45.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) start + 2015-01-28T20:25:45.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) die + 2015-01-28T20:25:46.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) stop # HISTORY April 2014, Originally compiled by William Henry (whenry at redhat dot com)