Cleanup pass through logging (#1073)
* added filtering for noisy pion logs * demoted some logs to debug * using consistent trackID / participant / publisher / subscriber terminology * removed ice candidate log lines, deferring to combined log
This commit is contained in:
@@ -2,6 +2,7 @@ package serverlogger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"go.uber.org/zap/zapcore"
|
||||
@@ -9,8 +10,9 @@ import (
|
||||
|
||||
// implements webrtc.LeveledLogger
|
||||
type logAdapter struct {
|
||||
logger logr.Logger
|
||||
level zapcore.Level
|
||||
logger logr.Logger
|
||||
level zapcore.Level
|
||||
ignoredPrefixes []string
|
||||
}
|
||||
|
||||
func (l *logAdapter) Trace(msg string) {
|
||||
@@ -39,6 +41,9 @@ func (l *logAdapter) Info(msg string) {
|
||||
if l.level > zapcore.InfoLevel {
|
||||
return
|
||||
}
|
||||
if l.shouldIgnore(msg) {
|
||||
return
|
||||
}
|
||||
l.logger.Info(msg)
|
||||
}
|
||||
|
||||
@@ -46,6 +51,9 @@ func (l *logAdapter) Infof(format string, args ...interface{}) {
|
||||
if l.level > zapcore.InfoLevel {
|
||||
return
|
||||
}
|
||||
if l.shouldIgnore(format) {
|
||||
return
|
||||
}
|
||||
l.logger.Info(fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
@@ -53,20 +61,29 @@ func (l *logAdapter) Warn(msg string) {
|
||||
if l.level > zapcore.WarnLevel {
|
||||
return
|
||||
}
|
||||
l.logger.Info(msg)
|
||||
if l.shouldIgnore(msg) {
|
||||
return
|
||||
}
|
||||
l.logger.V(-1).Info(msg)
|
||||
}
|
||||
|
||||
func (l *logAdapter) Warnf(format string, args ...interface{}) {
|
||||
if l.level > zapcore.WarnLevel {
|
||||
return
|
||||
}
|
||||
l.logger.Info(fmt.Sprintf(format, args...))
|
||||
if l.shouldIgnore(format) {
|
||||
return
|
||||
}
|
||||
l.logger.V(-1).Info(fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (l *logAdapter) Error(msg string) {
|
||||
if l.level > zapcore.ErrorLevel {
|
||||
return
|
||||
}
|
||||
if l.shouldIgnore(msg) {
|
||||
return
|
||||
}
|
||||
l.logger.Error(nil, msg)
|
||||
}
|
||||
|
||||
@@ -74,5 +91,17 @@ func (l *logAdapter) Errorf(format string, args ...interface{}) {
|
||||
if l.level > zapcore.ErrorLevel {
|
||||
return
|
||||
}
|
||||
if l.shouldIgnore(format) {
|
||||
return
|
||||
}
|
||||
l.logger.Error(nil, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (l *logAdapter) shouldIgnore(msg string) bool {
|
||||
for _, prefix := range l.ignoredPrefixes {
|
||||
if strings.HasPrefix(msg, prefix) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
+20
-3
@@ -11,7 +11,23 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
pionLevel zapcore.Level
|
||||
pionLevel zapcore.Level
|
||||
pionIgnoredPrefixes = map[string][]string{
|
||||
"ice": {
|
||||
"pingAllCandidates called with no candidate pairs",
|
||||
"failed to send packet",
|
||||
"Ignoring remote candidate with tcpType active",
|
||||
},
|
||||
"pc": {
|
||||
"Failed to accept RTCP stream is already closed",
|
||||
"Failed to accept RTP stream is already closed",
|
||||
"Incoming unhandled RTCP ssrc",
|
||||
},
|
||||
"tcp_mux": {
|
||||
"Error reading first packet from",
|
||||
"error closing connection",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// implements webrtc.LoggerFactory
|
||||
@@ -30,8 +46,9 @@ func NewLoggerFactory(logger logr.Logger) *LoggerFactory {
|
||||
|
||||
func (f *LoggerFactory) NewLogger(scope string) logging.LeveledLogger {
|
||||
return &logAdapter{
|
||||
logger: f.logger.WithName(scope),
|
||||
level: pionLevel,
|
||||
logger: f.logger.WithName(scope),
|
||||
level: pionLevel,
|
||||
ignoredPrefixes: pionIgnoredPrefixes[scope],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user