[tor-commits] [snowflake/master] Connect pion library logger with snowflake log

cohosh at torproject.org cohosh at torproject.org
Tue Oct 8 13:55:29 UTC 2019


commit 2b04357550a9fd827b8c1f35164de5ec42a63c7c
Author: Cecylia Bocovich <cohosh at torproject.org>
Date:   Wed Sep 4 15:00:58 2019 -0400

    Connect pion library logger with snowflake log
    
    We need to set up the pion/webrtc logger to write output to the
    snowflake log, otherwise the warnings we are getting from the pion
    library are being lost.
    
    Note: this requires go version 1.13 and later in order to use the
    `log.Writer()` function.
---
 client/lib/webrtc.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go
index dbc205e..e3245b6 100644
--- a/client/lib/webrtc.go
+++ b/client/lib/webrtc.go
@@ -9,6 +9,7 @@ import (
 	"time"
 
 	"github.com/dchest/uniuri"
+	"github.com/pion/logging"
 	"github.com/pion/webrtc"
 )
 
@@ -154,7 +155,14 @@ func (c *WebRTCPeer) preparePeerConnection() error {
 		c.pc.Close()
 		c.pc = nil
 	}
-	s := webrtc.SettingEngine{}
+
+	logFactory := logging.NewDefaultLoggerFactory()
+	logFactory.DefaultLogLevel = logging.LogLevelError
+	logFactory.Writer = log.Writer()
+
+	s := webrtc.SettingEngine{
+		LoggerFactory: logFactory,
+	}
 	s.SetTrickle(true)
 	api := webrtc.NewAPI(webrtc.WithSettingEngine(s))
 	pc, err := api.NewPeerConnection(*c.config)





More information about the tor-commits mailing list