Browse Source

Init log file as soon as possible (before calling psiphon package functions which may emit logs)

Rod Hynes 11 years ago
parent
commit
8996963baa
1 changed files with 11 additions and 11 deletions
  1. 11 11
      ConsoleClient/psiphonClient.go

+ 11 - 11
ConsoleClient/psiphonClient.go

@@ -60,6 +60,17 @@ func main() {
 		log.Fatalf("error processing configuration file: %s", err)
 		log.Fatalf("error processing configuration file: %s", err)
 	}
 	}
 
 
+	// Set logfile, if configured
+
+	if config.LogFilename != "" {
+		logFile, err := os.OpenFile(config.LogFilename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
+		if err != nil {
+			log.Fatalf("error opening log file: %s", err)
+		}
+		defer logFile.Close()
+		log.SetOutput(logFile)
+	}
+
 	// Handle optional profiling parameter
 	// Handle optional profiling parameter
 
 
 	if profileFilename != "" {
 	if profileFilename != "" {
@@ -100,17 +111,6 @@ func main() {
 		}
 		}
 	}
 	}
 
 
-	// Set logfile, if configured
-
-	if config.LogFilename != "" {
-		logFile, err := os.OpenFile(config.LogFilename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
-		if err != nil {
-			log.Fatalf("error opening log file: %s", err)
-		}
-		defer logFile.Close()
-		log.SetOutput(logFile)
-	}
-
 	// Run Psiphon
 	// Run Psiphon
 
 
 	controller := psiphon.NewController(config)
 	controller := psiphon.NewController(config)