forked from mirror/logrus
Add failing test for using a FieldLogger with hooks inside goroutines
This commit is contained in:
parent
768a92a026
commit
efbfdb5f09
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue