Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ func SetLogLevel(name, level string) error {
// wildcard, change all
if name == "*" {
SetAllLoggers(lvl)
loggerMutex.Lock()
defaultLevel = lvl
loggerMutex.Unlock()
return nil
}

Expand Down
20 changes: 20 additions & 0 deletions setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,23 @@ func TestSlogHandler_Concurrent(t *testing.T) {

wg.Wait()
}

func TestSetLogLevelConcurrentWildcard(t *testing.T) {
numCalls := 100
wg := sync.WaitGroup{}
wg.Add(numCalls)

for i := 0; i < numCalls; i++ {
go func(idx int) {
defer wg.Done()

lvl := "debug"
if idx%2 == 0 {
lvl = "info"
}
_ = SetLogLevel("*", lvl)
}(i)
}

wg.Wait()
}