Просмотр исходного кода

Allow -logfile on all platforms (fixes #2004)

Jakob Borg 10 лет назад
Родитель
Сommit
d63e54237b
2 измененных файлов с 6 добавлено и 10 удалено
  1. 5 9
      cmd/syncthing/main.go
  2. 1 1
      cmd/syncthing/monitor.go

+ 5 - 9
cmd/syncthing/main.go

@@ -218,11 +218,12 @@ func main() {
 	if runtime.GOOS == "windows" {
 		// On Windows, we use a log file by default. Setting the -logfile flag
 		// to "-" disables this behavior.
-
 		flag.StringVar(&logFile, "logfile", "", "Log file name (use \"-\" for stdout)")
 
 		// We also add an option to hide the 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")
@@ -262,14 +263,9 @@ func main() {
 		guiAssets = locations[locGUIAssets]
 	}
 
-	if runtime.GOOS == "windows" {
-		if logFile == "" {
-			// Use the default log file location
-			logFile = locations[locLogFile]
-		} else if logFile == "-" {
-			// Don't use a logFile
-			logFile = ""
-		}
+	if logFile == "" {
+		// Use the default log file location
+		logFile = locations[locLogFile]
 	}
 
 	if showVersion {

+ 1 - 1
cmd/syncthing/monitor.go

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