From 3bea0ca43ed9cec76f7d36080cf0a645d320851d Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 10 Oct 2016 12:35:38 +0200 Subject: log: fix test --- log/log.go | 7 ++++++- log/log_test.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/log/log.go b/log/log.go index cf1bad78a..9fff33497 100644 --- a/log/log.go +++ b/log/log.go @@ -25,6 +25,7 @@ var ( cacheMaxMem int cachePos int cacheEntries []string + prependTime bool // for testing ) // EnableCaching enables in memory caching of log output. @@ -73,7 +74,11 @@ func Logf(v int, msg string, args ...interface{}) { if cacheMem < 0 { panic("log cache size underflow") } - cacheEntries[cachePos] = fmt.Sprintf(time.Now().Format("2006/01/02 15:04:05 ")+msg, args...) + timeStr := "" + if prependTime { + timeStr = time.Now().Format("2006/01/02 15:04:05 ") + } + cacheEntries[cachePos] = fmt.Sprintf(timeStr+msg, args...) cacheMem += len(cacheEntries[cachePos]) cachePos++ if cachePos == len(cacheEntries) { diff --git a/log/log_test.go b/log/log_test.go index e21a8a78d..d179f0b87 100644 --- a/log/log_test.go +++ b/log/log_test.go @@ -21,6 +21,7 @@ func TestCaching(t *testing.T) { {"jjjjjjjjjjjjjjjjjjjjjjjjj", "jjjjjjjjjjjjjjjjjjjjjjjjj\n"}, } EnableLogCaching(4, 20) + prependTime = false for _, test := range tests { Logf(1000, test.str) out := CachedLogOutput() -- cgit mrf-deployment