diff --git a/p2p/host/eventbus/basic.go b/p2p/host/eventbus/basic.go index af6a74bd02..32051f54fb 100644 --- a/p2p/host/eventbus/basic.go +++ b/p2p/host/eventbus/basic.go @@ -14,6 +14,7 @@ import ( type logInterface interface { Errorf(string, ...interface{}) + Warnf(string, ...interface{}) } var log logInterface = logging.Logger("eventbus") @@ -464,7 +465,7 @@ func emitAndLogError(timer *time.Timer, typ reflect.Type, evt interface{}, sink <-timer.C } case <-timer.C: - log.Errorf("subscriber named \"%s\" is a slow consumer of %s. This can lead to libp2p stalling and hard to debug issues.", sink.name, typ) + log.Warnf("subscriber named \"%s\" is a slow consumer of %s. This can lead to libp2p stalling and hard to debug issues.", sink.name, typ) // Continue to stall since there's nothing else we can do. sink.ch <- evt } diff --git a/p2p/host/eventbus/basic_test.go b/p2p/host/eventbus/basic_test.go index 530a46ff19..b3fdb12e35 100644 --- a/p2p/host/eventbus/basic_test.go +++ b/p2p/host/eventbus/basic_test.go @@ -18,8 +18,10 @@ import ( "github.com/stretchr/testify/require" ) -type EventA struct{} -type EventB int +type ( + EventA struct{} + EventB int +) func getN() int { n := 50000 @@ -144,6 +146,10 @@ func (m *mockLogger) Errorf(format string, args ...interface{}) { m.logs = append(m.logs, fmt.Sprintf(format, args...)) } +func (m *mockLogger) Warnf(format string, args ...interface{}) { + m.Errorf(format, args...) +} + func (m *mockLogger) Logs() []string { m.mu.Lock() defer m.mu.Unlock()