]> Sergey Matveev's repositories - btrtrc.git/blobdiff - webtorrent/setting-engine.go
Fix webrtc logging for JS build
[btrtrc.git] / webtorrent / setting-engine.go
diff --git a/webtorrent/setting-engine.go b/webtorrent/setting-engine.go
new file mode 100644 (file)
index 0000000..a84ee02
--- /dev/null
@@ -0,0 +1,24 @@
+// These build constraints are copied from webrtc's settingengine.go.
+//go:build !js
+// +build !js
+
+package webtorrent
+
+import (
+       "io"
+
+       "github.com/pion/logging"
+       "github.com/pion/webrtc/v3"
+)
+
+var s = webrtc.SettingEngine{
+       // This could probably be done with better integration into anacrolix/log, but I'm not sure if
+       // it's worth the effort.
+       LoggerFactory: discardLoggerFactory{},
+}
+
+type discardLoggerFactory struct{}
+
+func (discardLoggerFactory) NewLogger(scope string) logging.LeveledLogger {
+       return logging.NewDefaultLeveledLoggerForScope(scope, logging.LogLevelInfo, io.Discard)
+}