summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-31 04:36:31 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-31 04:36:31 -0400
commit35965092fa3988844f3ed45627cd0d37a6371ae3 (patch)
tree756dd9a7db8848e0075c02ded026585fb7a51b55
parent4fa97eec3910f22159e51c2742049a5769a8f0a0 (diff)
downloadgetwtxt-35965092fa3988844f3ed45627cd0d37a6371ae3.tar.gz
bugfix: more incorrectly logged errors
-rw-r--r--http.go6
-rw-r--r--init.go10
-rw-r--r--main.go2
3 files changed, 9 insertions, 9 deletions
diff --git a/http.go b/http.go
index f4ba233..725f4c5 100644
--- a/http.go
+++ b/http.go
@@ -61,7 +61,7 @@ func log200(r *http.Request) {
 
 func log400(w http.ResponseWriter, r *http.Request, err string) {
 	uip := getIPFromCtx(r.Context())
-	log.Printf("*** %v :: 400 :: %v %v :: %v\n", uip, r.Method, r.URL, err)
+	log.Printf("*** %v :: 400 :: %v %v :: %v\n", uip, r.Method, r.URL, err.Error())
 	http.Error(w, "400 Bad Request: "+err, http.StatusBadRequest)
 }
 
@@ -69,7 +69,7 @@ func log404(w http.ResponseWriter, r *http.Request, err error) {
 	useragent := r.Header["User-Agent"]
 
 	uip := getIPFromCtx(r.Context())
-	log.Printf("*** %v :: 404 :: %v %v :: %v :: %v\n", uip, r.Method, r.URL, useragent, err)
+	log.Printf("*** %v :: 404 :: %v %v :: %v :: %v\n", uip, r.Method, r.URL, useragent, err.Error())
 	http.Error(w, err.Error(), http.StatusNotFound)
 }
 
@@ -77,6 +77,6 @@ func log500(w http.ResponseWriter, r *http.Request, err error) {
 	useragent := r.Header["User-Agent"]
 
 	uip := getIPFromCtx(r.Context())
-	log.Printf("*** %v :: 500 :: %v %v :: %v :: %v\n", uip, r.Method, r.URL, useragent, err)
+	log.Printf("*** %v :: 500 :: %v %v :: %v :: %v\n", uip, r.Method, r.URL, useragent, err.Error())
 	http.Error(w, err.Error(), http.StatusInternalServerError)
 }
diff --git a/init.go b/init.go
index 34b2621..1e9e9e3 100644
--- a/init.go
+++ b/init.go
@@ -108,7 +108,7 @@ func initConfig() {
 
 	log.Printf("Loading configuration ...\n")
 	if err := viper.ReadInConfig(); err != nil {
-		log.Printf("%v\n", err)
+		log.Printf("%v\n", err.Error())
 		log.Printf("Using defaults ...\n")
 	} else {
 		viper.WatchConfig()
@@ -177,7 +177,7 @@ func initLogging() {
 
 		logfile, err := os.OpenFile(confObj.LogFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
 		if err != nil {
-			log.Printf("Could not open log file: %v\n", err)
+			log.Printf("Could not open log file: %v\n", err.Error())
 		}
 
 		// Listen for the signal to close the log file
@@ -191,7 +191,7 @@ func initLogging() {
 
 			err = logfile.Close()
 			if err != nil {
-				log.Printf("Couldn't close log file: %v\n", err)
+				log.Printf("Couldn't close log file: %v\n", err.Error())
 			}
 		}(logfile)
 
@@ -238,7 +238,7 @@ func initDatabase() {
 	db, err := leveldb.OpenFile(confObj.DBPath, nil)
 	confObj.Mu.RUnlock()
 	if err != nil {
-		log.Fatalf("%v\n", err)
+		log.Fatalf("%v\n", err.Error())
 	}
 
 	dbChan <- db
@@ -262,7 +262,7 @@ func watchForInterrupt() {
 			log.Printf("Closing database connection to %v...\n", confObj.DBPath)
 			db := <-dbChan
 			if err := db.Close(); err != nil {
-				log.Printf("%v\n", err)
+				log.Printf("%v\n", err.Error())
 			}
 
 			if !confObj.StdoutLogging {
diff --git a/main.go b/main.go
index ff0447e..6f50f68 100644
--- a/main.go
+++ b/main.go
@@ -97,7 +97,7 @@ func main() {
 	log.Printf("Listening on %v\n", portnum)
 	err := server.ListenAndServe()
 	if err != nil {
-		log.Printf("%v\n", err)
+		log.Printf("%v\n", err.Error())
 	}
 
 	closeLog <- true