diff --git a/logger_test.go b/logger_test.go index 8e9d5a9..63b5a05 100644 --- a/logger_test.go +++ b/logger_test.go @@ -957,6 +957,21 @@ func TestInvalidFile(t *testing.T) { } } +func TestConcurrentLevelSet(t *testing.T) { + // This test is to make sure that setting the log level concurrently + // doesn't cause a -race failure. Shows up in dflag/ for instance with configmap changes. + var wg sync.WaitGroup + wg.Add(int(Fatal - Verbose)) + for i := Verbose; i < Fatal; i++ { + go func() { + SetLogLevel(i) + wg.Done() + }() + } + wg.Wait() + SetLogLevel(Info) +} + // --- Benchmarks // This `discard` is like io.Discard, except that io.Discard is checked explicitly