Allow -logfile on all platforms (fixes #2004)

This commit is contained in:
Jakob Borg 2015-08-27 18:19:06 +02:00
parent e256d93b43
commit d63e54237b
2 changed files with 6 additions and 10 deletions

View File

@ -218,11 +218,12 @@ func main() {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
// On Windows, we use a log file by default. Setting the -logfile flag // On Windows, we use a log file by default. Setting the -logfile flag
// to "-" disables this behavior. // to "-" disables this behavior.
flag.StringVar(&logFile, "logfile", "", "Log file name (use \"-\" for stdout)") flag.StringVar(&logFile, "logfile", "", "Log file name (use \"-\" for stdout)")
// We also add an option to hide the console window // We also add an option to hide the console window
flag.BoolVar(&noConsole, "no-console", false, "Hide console window") flag.BoolVar(&noConsole, "no-console", false, "Hide console window")
} else {
flag.StringVar(&logFile, "logfile", "-", "Log file name (use \"-\" for stdout)")
} }
flag.StringVar(&generateDir, "generate", "", "Generate key and config in specified dir, then exit") flag.StringVar(&generateDir, "generate", "", "Generate key and config in specified dir, then exit")
@ -262,14 +263,9 @@ func main() {
guiAssets = locations[locGUIAssets] guiAssets = locations[locGUIAssets]
} }
if runtime.GOOS == "windows" {
if logFile == "" { if logFile == "" {
// Use the default log file location // Use the default log file location
logFile = locations[locLogFile] logFile = locations[locLogFile]
} else if logFile == "-" {
// Don't use a logFile
logFile = ""
}
} }
if showVersion { if showVersion {

View File

@ -40,7 +40,7 @@ func monitorMain() {
var err error var err error
var dst io.Writer = os.Stdout var dst io.Writer = os.Stdout
if logFile != "" { if logFile != "-" {
var fileDst io.Writer var fileDst io.Writer
fileDst, err = os.Create(logFile) fileDst, err = os.Create(logFile)