fix ReportCaller race condition

This commit is contained in:
georlav
2019-03-04 20:38:10 +02:00
parent c9b4f5af6d
commit b9d451406d
2 changed files with 19 additions and 0 deletions
+17
View File
@@ -743,3 +743,20 @@ func TestReportCallerOnTextFormatter(t *testing.T) {
l.Formatter.(*TextFormatter).DisableColors = true
l.WithFields(Fields{"func": "func", "file": "file"}).Info("test")
}
func TestSetReportCallerRace(t *testing.T) {
l := New()
l.Out = ioutil.Discard
l.SetReportCaller(true)
var wg sync.WaitGroup
wg.Add(100)
for i := 0; i < 100; i++ {
go func() {
l.Error("Some Error")
wg.Done()
}()
}
wg.Wait()
}