Merge pull request 'change file logging behaviour to use cwtch dir' (#382) from dan/ui:winLog into master
the build failed
Details
the build failed
Details
Reviewed-on: #382
This commit is contained in:
commit
4805507014
39
main.go
39
main.go
|
@ -44,6 +44,19 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if os.Getenv("CWTCH_FOLDER") != "" {
|
||||||
|
the.CwtchDir = os.Getenv("CWTCH_FOLDER")
|
||||||
|
} else if runtime.GOOS == "android" {
|
||||||
|
the.CwtchDir = filepath.Join(androidBaseDir, "files")
|
||||||
|
} else {
|
||||||
|
usr, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("\nerror: could not load current user: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
the.CwtchDir = filepath.Join(usr.HomeDir, ".cwtch")
|
||||||
|
}
|
||||||
|
|
||||||
// suppress event.NewMessageFromPeer so we can handle it ourselves
|
// suppress event.NewMessageFromPeer so we can handle it ourselves
|
||||||
peer.DefaultEventsToHandle = []event.Type{
|
peer.DefaultEventsToHandle = []event.Type{
|
||||||
event.EncryptedGroupMessage,
|
event.EncryptedGroupMessage,
|
||||||
|
@ -54,26 +67,21 @@ func main() {
|
||||||
event.NewGetValMessageFromPeer,
|
event.NewGetValMessageFromPeer,
|
||||||
}
|
}
|
||||||
|
|
||||||
logfileDefault := ""
|
logfileDefault := "cwtch_log.txt"
|
||||||
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!")
|
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")
|
flagLogFile := flag.Bool("logfile", false, "instead of console output, log to $HOME/.cwtch/"+logfileDefault)
|
||||||
flagLocal := flag.Bool("local", false, "load user interface from the local folder \"qml\" instead of the built-in UI")
|
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")
|
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")
|
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()
|
flag.Parse()
|
||||||
|
|
||||||
if *flagLogFile != "" && !*flagConsole {
|
if *flagLogFile {
|
||||||
filelogger, err := log.NewFile(log.LevelInfo, *flagLogFile)
|
filelogger, err := log.NewFile(log.LevelInfo, filepath.Join(the.CwtchDir, logfileDefault))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.SetStd(filelogger)
|
log.SetStd(filelogger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Infoln("ui main()\n")
|
|
||||||
|
|
||||||
if *flagDebug {
|
if *flagDebug {
|
||||||
log.SetLevel(log.LevelDebug)
|
log.SetLevel(log.LevelDebug)
|
||||||
|
@ -93,18 +101,7 @@ func main() {
|
||||||
log.ExcludeFromPattern("applications/auth.go")
|
log.ExcludeFromPattern("applications/auth.go")
|
||||||
//log.ExcludeFromPattern("connections/engine.go")
|
//log.ExcludeFromPattern("connections/engine.go")
|
||||||
|
|
||||||
if os.Getenv("CWTCH_FOLDER") != "" {
|
log.Infoln("ui main()")
|
||||||
the.CwtchDir = os.Getenv("CWTCH_FOLDER")
|
|
||||||
} else if runtime.GOOS == "android" {
|
|
||||||
the.CwtchDir = filepath.Join(androidBaseDir, "files")
|
|
||||||
} else {
|
|
||||||
usr, err := user.Current()
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("\nerror: could not load current user: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
the.CwtchDir = filepath.Join(usr.HomeDir, ".cwtch")
|
|
||||||
}
|
|
||||||
|
|
||||||
if buildVer == "" && os.Getenv("CWTCH_FOLDER") == "" {
|
if buildVer == "" && os.Getenv("CWTCH_FOLDER") == "" {
|
||||||
log.Infoln("Development build: using dev directory for dev profiles")
|
log.Infoln("Development build: using dev directory for dev profiles")
|
||||||
|
|
Reference in New Issue