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.
This commit is contained in:
Cecylia Bocovich 2019-09-04 15:00:58 -04:00
parent 97bab94e67
commit 2b04357550

View file

@ -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)