Make BytesSyncLogger's implementation details internal.

Provide NewBytesSyncLogger that returns an opaque data structure.
Automatically start up the logging loop goroutine in NewBytesSyncLogger.
This commit is contained in:
David Fifield 2020-04-23 21:20:16 -06:00
parent 9a4e3e7bd9
commit 2853fc9362
2 changed files with 29 additions and 33 deletions

View file

@ -161,15 +161,7 @@ func main() {
snowflakes.Tongue = sf.NewWebRTCDialer(broker, iceServers)
// Use a real logger to periodically output how much traffic is happening.
snowflakes.BytesLogger = &sf.BytesSyncLogger{
InboundChan: make(chan int, 5),
OutboundChan: make(chan int, 5),
Inbound: 0,
Outbound: 0,
InEvents: 0,
OutEvents: 0,
}
go snowflakes.BytesLogger.Log()
snowflakes.BytesLogger = sf.NewBytesSyncLogger()
go ConnectLoop(snowflakes)