]> Sergey Matveev's repositories - btrtrc.git/commitdiff
discard logger factory
authoralex.sharov <AskAlexSharov@gmail.com>
Sat, 9 Apr 2022 07:06:05 +0000 (14:06 +0700)
committeralex.sharov <AskAlexSharov@gmail.com>
Sat, 9 Apr 2022 07:06:05 +0000 (14:06 +0700)
webtorrent/transport.go

index 62ca5fdb4b80fcac7a0b840165077b6529a024a3..511ab59583999f67e55a08ee3748957348f6da44 100644 (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))
        }()