Commit 12922a23 authored by David Fifield's avatar David Fifield
Browse files

Make logging optional and controlled by a -log option.

parent f418ec7a
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
"net" "net"
"os" "os"
"os/signal" "os/signal"
"path"
"sync" "sync"
"syscall" "syscall"
"time" "time"
...@@ -122,29 +121,28 @@ func copyLoop(a, b io.ReadWriter) { ...@@ -122,29 +121,28 @@ func copyLoop(a, b io.ReadWriter) {
} }
func main() { func main() {
var iceServers IceServerList
flag.Var(&iceServers, "ice", "comma-separated list of ICE servers")
brokerURL := flag.String("url", "", "URL of signaling broker")
frontDomain := flag.String("front", "", "front domain")
logFilename := flag.String("log", "", "name of log file")
max := flag.Int("max", DefaultSnowflakeCapacity,
"capacity for number of multiplexed WebRTC peers")
flag.Parse()
webrtc.SetLoggingVerbosity(1) webrtc.SetLoggingVerbosity(1)
stateDir, err := pt.MakeStateDir() if *logFilename != "" {
if err != nil { logFile, err := os.OpenFile(*logFilename,
log.Fatal(err)
}
logFile, err := os.OpenFile(path.Join(stateDir, "snowflake.log"),
os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
defer logFile.Close() defer logFile.Close()
log.SetOutput(logFile) log.SetOutput(logFile)
}
var iceServers IceServerList
log.Println("\n\n\n --- Starting Snowflake Client ---") log.Println("\n\n\n --- Starting Snowflake Client ---")
flag.Var(&iceServers, "ice", "comma-separated list of ICE servers")
brokerURL := flag.String("url", "", "URL of signaling broker")
frontDomain := flag.String("front", "", "front domain")
max := flag.Int("max", DefaultSnowflakeCapacity,
"capacity for number of multiplexed WebRTC peers")
flag.Parse()
// Prepare to collect remote WebRTC peers. // Prepare to collect remote WebRTC peers.
snowflakes := NewPeers(*max) snowflakes := NewPeers(*max)
if "" != *brokerURL { if "" != *brokerURL {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment