Merge pull request #10424 from LK4D4/fix_non_tailed_log_format

Fix logs, so now, old and followed logs has same format without []
Upstream-commit: e4a49ae1885a7f80e713d1d1fc852f6e4214dfe6
Component: engine
This commit is contained in:
Michael Crosby
2015-02-06 14:35:45 -08:00
4 changed files with 18 additions and 16 deletions

View File

@ -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() {

View File

@ -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)