Add failing test for using a FieldLogger with hooks inside goroutines

This commit is contained in:
Michael Haines 2018-02-05 12:42:00 -07:00
parent 768a92a026
commit efbfdb5f09
1 changed files with 18 additions and 0 deletions

View File

@ -343,6 +343,24 @@ func TestLoggingRace(t *testing.T) {
wg.Wait()
}
func TestLoggingRaceWithHooksOnFieldLogger(t *testing.T) {
logger := New()
hook := new(ModifyHook)
logger.AddHook(hook)
fieldLogger := logger.WithField("context", "clue")
var wg sync.WaitGroup
wg.Add(100)
for i := 0; i < 100; i++ {
go func() {
fieldLogger.Info("info")
wg.Done()
}()
}
wg.Wait()
}
// Compile test
func TestLogrusInterface(t *testing.T) {
var buffer bytes.Buffer