From: alex.sharov Date: Sat, 9 Apr 2022 07:06:05 +0000 (+0700) Subject: discard logger factory X-Git-Tag: v1.42.0~1^2~1 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=fc3faca11785ac7a3cf5b7fb6afbd8fb15ce9e46;p=btrtrc.git discard logger factory --- diff --git a/webtorrent/transport.go b/webtorrent/transport.go index 62ca5fdb..511ab595 100644 --- a/webtorrent/transport.go +++ b/webtorrent/transport.go @@ -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)) }()