Explorar o código

Explicitly configure default logfile for stderr

Jonathon Reinhart %!s(int64=4) %!d(string=hai) anos
pai
achega
9921b38046
Modificáronse 2 ficheiros con 4 adicións e 2 borrados
  1. 3 1
      logger.go
  2. 1 1
      smtprelay.ini

+ 3 - 1
logger.go

@@ -16,7 +16,9 @@ func setupLogger() {
 	log = logrus.New()
 
 	// Handle logfile
-	if (*logFile != "") {
+	if (*logFile == "") {
+		log.SetOutput(os.Stderr)
+	} else {
 		writer, err := os.OpenFile(*logFile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0600)
 		if err != nil {
 			fmt.Printf("cannot open log file: %s\n", err)

+ 1 - 1
smtprelay.ini

@@ -1,6 +1,6 @@
 ; smtprelay configuration
 
-; Logfile
+; Logfile (blank/default is stderr)
 ;logfile = 
 
 ; Log format: default, plain (no timestamp), json