From b28d0ff4cf40adafe940842907e7c1d8451d704c Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 10 Oct 2016 12:58:27 +0200 Subject: log: don't cache messages with verbosity>1 Infinite verbosity produces too much noise, so don't cache messages with verbosity>1. Need something better later, e.g. ability to view messages for different verbosity levels. --- log/log.go | 2 +- log/log_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/log/log.go b/log/log.go index 9fff33497..b17fb13e0 100644 --- a/log/log.go +++ b/log/log.go @@ -69,7 +69,7 @@ func DisableLog() { func Logf(v int, msg string, args ...interface{}) { mu.Lock() doLog := v <= *flagV && (v < 0 || !disabled) - if cacheEntries != nil { + if cacheEntries != nil && v <= 1 { cacheMem -= len(cacheEntries[cachePos]) if cacheMem < 0 { panic("log cache size underflow") diff --git a/log/log_test.go b/log/log_test.go index d179f0b87..cb40aceab 100644 --- a/log/log_test.go +++ b/log/log_test.go @@ -23,7 +23,7 @@ func TestCaching(t *testing.T) { EnableLogCaching(4, 20) prependTime = false for _, test := range tests { - Logf(1000, test.str) + Logf(1, test.str) out := CachedLogOutput() if out != test.want { t.Fatalf("wrote: %v\nwant: %v\ngot: %v", test.str, test.want, out) -- cgit mrf-deployment