mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 01:04:14 +00:00
Allow -logfile on all platforms (fixes #2004)
This commit is contained in:
parent
e256d93b43
commit
d63e54237b
@ -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 {
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user