New logger for the Traefik logs
This commit is contained in:
parent
27c02b5a56
commit
56f7515ecd
297 changed files with 2337 additions and 1934 deletions
|
@ -11,9 +11,9 @@ import (
|
|||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
||||
"github.com/traefik/traefik/v2/pkg/healthcheck"
|
||||
"github.com/traefik/traefik/v2/pkg/log"
|
||||
"github.com/traefik/traefik/v2/pkg/middlewares/accesslog"
|
||||
"github.com/traefik/traefik/v2/pkg/safe"
|
||||
)
|
||||
|
@ -82,18 +82,18 @@ func (m *Mirroring) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
logger := log.FromContext(req.Context())
|
||||
logger := log.Ctx(req.Context())
|
||||
rr, bytesRead, err := newReusableRequest(req, m.maxBodySize)
|
||||
if err != nil && !errors.Is(err, errBodyTooLarge) {
|
||||
http.Error(rw, http.StatusText(http.StatusInternalServerError)+
|
||||
fmt.Sprintf("error creating reusable request: %v", err), http.StatusInternalServerError)
|
||||
http.Error(rw, fmt.Sprintf("%s: creating reusable request: %v",
|
||||
http.StatusText(http.StatusInternalServerError), err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, errBodyTooLarge) {
|
||||
req.Body = io.NopCloser(io.MultiReader(bytes.NewReader(bytesRead), req.Body))
|
||||
m.handler.ServeHTTP(rw, req)
|
||||
logger.Debug("no mirroring, request body larger than allowed size")
|
||||
logger.Debug().Msg("No mirroring, request body larger than allowed size")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ func (m *Mirroring) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
select {
|
||||
case <-req.Context().Done():
|
||||
// No mirroring if request has been canceled during main handler ServeHTTP
|
||||
logger.Warn("no mirroring, request has been canceled during main handler ServeHTTP")
|
||||
logger.Warn().Msg("No mirroring, request has been canceled during main handler ServeHTTP")
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func (b blackHoleResponseWriter) Write(data []byte) (int, error) {
|
|||
return len(data), nil
|
||||
}
|
||||
|
||||
func (b blackHoleResponseWriter) WriteHeader(statusCode int) {}
|
||||
func (b blackHoleResponseWriter) WriteHeader(_ int) {}
|
||||
|
||||
type contextStopPropagation struct {
|
||||
context.Context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue