diff pkg/controllers/proxy.go @ 5490:5f47eeea988d logging

Use own logging package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 20 Sep 2021 17:45:39 +0200
parents f4ec3558460e
children 31973f6f5cca
line wrap: on
line diff
--- a/pkg/controllers/proxy.go	Sat Aug 21 15:01:52 2021 +0200
+++ b/pkg/controllers/proxy.go	Mon Sep 20 17:45:39 2021 +0200
@@ -22,7 +22,6 @@
 	"encoding/xml"
 	"io"
 	"io/ioutil"
-	"log"
 	"net/http"
 	"net/url"
 	"regexp"
@@ -32,6 +31,7 @@
 	"golang.org/x/net/html/charset"
 
 	"gemma.intevation.de/gemma/pkg/config"
+	"gemma.intevation.de/gemma/pkg/log"
 	"gemma.intevation.de/gemma/pkg/middleware"
 )
 
@@ -53,10 +53,10 @@
 
 	return func(req *http.Request) {
 
-		//log.Printf("proxyDirector: %s\n", req.RequestURI)
+		//log.Debugf("proxyDirector: %s\n", req.RequestURI)
 
 		abort := func(format string, args ...interface{}) {
-			log.Printf(format, args...)
+			log.Errorf(format, args...)
 			panic(http.ErrAbortHandler)
 		}
 
@@ -66,7 +66,7 @@
 
 		if entry, found := vars["entry"]; found {
 			if s, found = lookup(entry); !found {
-				log.Printf("warn: cannot find entry '%s'\n", entry)
+				log.Warnf("cannot find entry '%s'\n", entry)
 				panic(middleware.ErrNotFound)
 			}
 		} else {
@@ -91,7 +91,7 @@
 		}
 
 		nURL := s + "?" + req.URL.RawQuery
-		//log.Printf("%v\n", nURL)
+		//log.Debugf("%v\n", nURL)
 
 		u, err := url.Parse(nURL)
 		if err != nil {
@@ -101,7 +101,7 @@
 
 		req.Host = u.Host
 		//req.Header.Del("If-None-Match")
-		//log.Printf("headers: %v\n", req.Header)
+		//log.Debugf("headers: %v\n", req.Header)
 	}
 }
 
@@ -117,7 +117,7 @@
 ) {
 	switch enc := h.Get("Content-Encoding"); {
 	case strings.Contains(enc, "gzip"):
-		//log.Println("info: gzip compression")
+		//log.Debugf("gzip compression")
 		return func(r io.Reader) (io.ReadCloser, error) {
 				return gzip.NewReader(r)
 			},
@@ -125,7 +125,7 @@
 				return gzip.NewWriter(w), nil
 			}
 	case strings.Contains(enc, "deflate"):
-		//log.Println("info: deflate compression")
+		//log.Debugf("deflate compression")
 		return func(r io.Reader) (io.ReadCloser, error) {
 				return flate.NewReader(r), nil
 			},
@@ -133,7 +133,7 @@
 				return flate.NewWriter(w, flate.DefaultCompression)
 			}
 	default:
-		//log.Println("info: no content compression")
+		//log.Debugf("no content compression")
 		return func(r io.Reader) (io.ReadCloser, error) {
 				if r2, ok := r.(io.ReadCloser); ok {
 					return r2, nil
@@ -184,10 +184,10 @@
 				w.Close()
 				pw.Close()
 				force.Close()
-				//log.Printf("info: rewrite took %s\n", time.Since(start))
+				//log.Debugf("rewrite took %s\n", time.Since(start))
 			}()
 			if err := rewrite(suffix, w, r); err != nil {
-				log.Printf("error: rewrite failed: %v\n", err)
+				log.Errorf("rewrite failed: %v\n", err)
 				return
 			}
 		}(resp.Body)