discard logger factory

This commit is contained in:
alex.sharov 2022-04-09 14:06:05 +07:00
parent d0dd0a4057
commit fc3faca117
1 changed files with 10 additions and 1 deletions

View File

@ -8,15 +8,24 @@ import (
"github.com/anacrolix/missinggo/v2/pproffd"
"github.com/pion/datachannel"
"github.com/pion/logging"
"github.com/pion/webrtc/v3"
)
type DiscardLoggerFactory struct{}
func (f *DiscardLoggerFactory) NewLogger(scope string) logging.LeveledLogger {
return logging.NewDefaultLeveledLoggerForScope(scope, logging.LogLevelInfo, io.Discard)
}
var (
metrics = expvar.NewMap("webtorrent")
api = func() *webrtc.API {
// Enable the detach API (since it's non-standard but more idiomatic).
s := webrtc.SettingEngine{}
s := webrtc.SettingEngine{
LoggerFactory: &DiscardLoggerFactory{},
}
s.DetachDataChannels()
return webrtc.NewAPI(webrtc.WithSettingEngine(s))
}()