From 568b979698feb54feed1438eb40f6e134d2bba90 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Fri, 13 Nov 2020 12:13:53 -0800 Subject: [PATCH] allow cwtch to log to file --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 652d1ed4..6bcf5675 100644 --- a/main.go +++ b/main.go @@ -54,16 +54,21 @@ func main() { event.NewGetValMessageFromPeer, } + logfileDefault := "" + if runtime.GOOS == "windows" { + logfileDefault = "cwtch_log.txt" + } flagDebug := flag.Bool("debug", false, "turn on extra logging. WARNING: THIS MAY EXPOSE PRIVATE INFORMATION IN CONSOLE OUTPUT!") + flagLogFile := flag.String("logfile", logfileDefault, "specify a file name to log to. --console overrides") flagLocal := flag.Bool("local", false, "load user interface from the local folder \"qml\" instead of the built-in UI") flagService := flag.Bool("service", false, "run this process as an android service") flagClientUI := flag.Bool("clientui", false, "start the UI as a client of a service app instead of a full app") flagConsole := flag.Bool("console", false, "on windows, force logging to console instead of file") flag.Parse() - if runtime.GOOS == "windows" && !*flagConsole { - filelogger, err := log.NewFile(log.LevelInfo, "cwtch_log.txt") + if *flagLogFile != "" && !*flagConsole { + filelogger, err := log.NewFile(log.LevelInfo, *flagLogFile) if err == nil { log.SetStd(filelogger) } @@ -305,7 +310,7 @@ func loadNetworkingAndFiles(gcd *ui.GrandCentralDispatcher, service bool, client } loadACN() - pid,err := the.ACN.GetPID() + pid, err := the.ACN.GetPID() if err == nil { gcd.GlobalSettings.PreviousPid = int64(pid) ui.WriteGlobalSettings(gcd.GlobalSettings)