change to use logging instead of print to stdout

This commit is contained in:
2023-04-03 12:00:01 +10:00
parent f2ac6097d6
commit 5cc67501d3
11 changed files with 88 additions and 87 deletions

View File

@@ -35,6 +35,7 @@ func main() {
fmt.Println("Unable to write logfile", err)
os.Exit(1)
}
log.SetOutput(logfileWriter)
// Initiate connection to sqlite and make sure our schema is up to date
models.ConnectDatabase()
@@ -88,7 +89,7 @@ func main() {
bindIP = "8443"
}
bindAddress := fmt.Sprint(bindIP, ":", bindPort)
fmt.Printf("Will listen on address 'https://%s'\n", bindAddress)
log.Printf("Will listen on address 'https://%s'\n", bindAddress)
// Get file names for TLS cert/key
tlsCertFilename := os.Getenv("TLS_CERT_FILE")
@@ -107,7 +108,7 @@ func main() {
// Generate certificate if required
if !(utils.FileExists(tlsCertFilename) && utils.FileExists(tlsKeyFilename)) {
fmt.Printf("Specified TLS certificate (%s) or private key (%s) do not exist.\n", tlsCertFilename, tlsKeyFilename)
log.Printf("Specified TLS certificate (%s) or private key (%s) do not exist.\n", tlsCertFilename, tlsKeyFilename)
utils.GenerateCerts(tlsCertFilename, tlsKeyFilename)
}