Skip to content

Commit 5d5f8d7

Browse files
authored
fix(webrtc): use debug level for pion errors (#3426)
1 parent d0ecbf9 commit 5d5f8d7

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

p2p/transport/webrtc/logger.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ var log = logging.Logger("webrtc-transport")
1414
// pionLog is the logger provided to pion for internal logging
1515
var pionLog = logging.Logger("webrtc-transport-pion")
1616

17-
// pionLogger wraps the StandardLogger interface to provide a LeveledLogger interface
18-
// as expected by pion
19-
// Pion logs are too noisy and have invalid log levels. pionLogger downgrades all the
20-
// logs to debug
17+
// pionLogger adapts pion's logger to go-libp2p's semantics.
18+
// Pion logs routine connection events (client disconnects, protocol mismatches,
19+
// state races) as ERROR/WARN, but these are normal operational noise from a
20+
// service perspective. We downgrade all pion logs to DEBUG to prevent log spam
21+
// while preserving debuggability when needed.
2122
type pionLogger struct {
2223
*slog.Logger
2324
}
@@ -37,32 +38,32 @@ func (l pionLogger) Debugf(s string, args ...interface{}) {
3738
}
3839

3940
func (l pionLogger) Error(s string) {
40-
l.Logger.Error(s)
41+
l.Logger.Debug(s)
4142
}
4243

4344
func (l pionLogger) Errorf(s string, args ...interface{}) {
44-
if l.Logger.Enabled(context.Background(), slog.LevelError) {
45-
l.Logger.Error(fmt.Sprintf(s, args...))
45+
if l.Logger.Enabled(context.Background(), slog.LevelDebug) {
46+
l.Logger.Debug(fmt.Sprintf(s, args...))
4647
}
4748
}
4849

4950
func (l pionLogger) Info(s string) {
50-
l.Logger.Info(s)
51+
l.Logger.Debug(s)
5152
}
5253

5354
func (l pionLogger) Infof(s string, args ...interface{}) {
54-
if l.Logger.Enabled(context.Background(), slog.LevelInfo) {
55-
l.Logger.Info(fmt.Sprintf(s, args...))
55+
if l.Logger.Enabled(context.Background(), slog.LevelDebug) {
56+
l.Logger.Debug(fmt.Sprintf(s, args...))
5657
}
5758
}
5859

5960
func (l pionLogger) Warn(s string) {
60-
l.Logger.Warn(s)
61+
l.Logger.Debug(s)
6162
}
6263

6364
func (l pionLogger) Warnf(s string, args ...interface{}) {
64-
if l.Logger.Enabled(context.Background(), slog.LevelWarn) {
65-
l.Logger.Warn(fmt.Sprintf(s, args...))
65+
if l.Logger.Enabled(context.Background(), slog.LevelDebug) {
66+
l.Logger.Debug(fmt.Sprintf(s, args...))
6667
}
6768
}
6869

0 commit comments

Comments
 (0)