mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
chore(http): set log level to trace (#765)
This commit is contained in:
parent
4ade1b0ecf
commit
0d6e23f278
1 changed files with 19 additions and 16 deletions
|
@ -3,6 +3,7 @@ package http
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5/middleware"
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
|
@ -61,22 +62,24 @@ func LoggerMiddleware(logger *zerolog.Logger) func(next http.Handler) http.Handl
|
||||||
http.Error(ww, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
http.Error(ww, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// log end request
|
if !strings.Contains("/api/healthz/liveness|/api/healthz/readiness", r.URL.Path) {
|
||||||
log.Info().
|
// log end request
|
||||||
Str("type", "access").
|
log.Trace().
|
||||||
Timestamp().
|
Str("type", "access").
|
||||||
Fields(map[string]interface{}{
|
Timestamp().
|
||||||
"remote_ip": r.RemoteAddr,
|
Fields(map[string]interface{}{
|
||||||
"url": r.URL.Path,
|
"remote_ip": r.RemoteAddr,
|
||||||
"proto": r.Proto,
|
"url": r.URL.Path,
|
||||||
"method": r.Method,
|
"proto": r.Proto,
|
||||||
"user_agent": r.Header.Get("User-Agent"),
|
"method": r.Method,
|
||||||
"status": ww.Status(),
|
"user_agent": r.Header.Get("User-Agent"),
|
||||||
"latency_ms": float64(t2.Sub(t1).Nanoseconds()) / 1000000.0,
|
"status": ww.Status(),
|
||||||
"bytes_in": r.Header.Get("Content-Length"),
|
"latency_ms": float64(t2.Sub(t1).Nanoseconds()) / 1000000.0,
|
||||||
"bytes_out": ww.BytesWritten(),
|
"bytes_in": r.Header.Get("Content-Length"),
|
||||||
}).
|
"bytes_out": ww.BytesWritten(),
|
||||||
Msg("incoming_request")
|
}).
|
||||||
|
Msg("incoming_request")
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
next.ServeHTTP(ww, r)
|
next.ServeHTTP(ww, r)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue