feat: add option to log every request with path and IP

This commit is contained in:
crapStone 2025-06-12 22:57:04 +02:00 committed by crapStone
parent 2b2f280bc3
commit 023ea17492
5 changed files with 30 additions and 0 deletions

View file

@ -28,6 +28,10 @@ func Handler(
return func(w http.ResponseWriter, req *http.Request) {
ctx := context.New(w, req)
log := log.With().Str("ReqId", ctx.ReqId).Strs("Handler", []string{req.Host, req.RequestURI}).Logger()
if cfg.LogEveryRequest {
log.Log().Str("IP", req.RemoteAddr).Msg("new request")
}
log.Debug().Msg("\n----------------------------------------------------------")
ctx.RespWriter.Header().Set("Server", "pages-server")