mirror of
https://github.com/nais/wonderwall.git
synced 2026-08-23 21:16:14 +00:00
feat(reverseproxy): configure errorlog to use logrus implementation
This commit is contained in:
@@ -2,9 +2,12 @@ package reverseproxy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/nais/wonderwall/pkg/handler/autologin"
|
||||
"github.com/nais/wonderwall/pkg/handler/url"
|
||||
"github.com/nais/wonderwall/pkg/loginstatus"
|
||||
@@ -44,6 +47,7 @@ func New(upstreamHost string) *ReverseProxy {
|
||||
logger.Warnf("reverseproxy: proxy error: %+v", err)
|
||||
w.WriteHeader(http.StatusBadGateway)
|
||||
},
|
||||
ErrorLog: log.New(logrusErrorWriter{}, "reverseproxy: ", 0),
|
||||
}
|
||||
return &ReverseProxy{rp}
|
||||
}
|
||||
@@ -87,3 +91,10 @@ func (rp *ReverseProxy) Handler(src Source, w http.ResponseWriter, r *http.Reque
|
||||
|
||||
rp.ServeHTTP(w, r.WithContext(ctx))
|
||||
}
|
||||
|
||||
type logrusErrorWriter struct{}
|
||||
|
||||
func (w logrusErrorWriter) Write(p []byte) (n int, err error) {
|
||||
logrus.Warnf("%s", string(p))
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user