improved logging

This commit is contained in:
ston1th 2022-09-19 22:52:40 +02:00
commit 05b41cedce
81 changed files with 9802 additions and 279 deletions

View file

@ -1,16 +1,27 @@
// Copyright (C) 2021 Marius Schellenberger
// Copyright (C) 2022 Marius Schellenberger
package server
import (
"git.giftfish.de/ston1th/docstore/pkg/log"
"net/http"
"github.com/go-logr/logr"
)
func webdavLogger(r *http.Request, err error) {
if err != nil {
log.Printf("webdav: %s %s %s error: %s\n", r.RemoteAddr, r.Method, r.URL, err)
return
func webdavLogger(log logr.Logger) func(r *http.Request, err error) {
return func(r *http.Request, err error) {
if err != nil {
log.Error(err, "access",
"client", r.RemoteAddr,
"method", r.Method,
"uri", r.URL.Path,
)
return
}
log.Info("access",
"client", r.RemoteAddr,
"method", r.Method,
"uri", r.URL.Path,
)
}
log.Printf("webdav: %s %s %s\n", r.RemoteAddr, r.Method, r.URL)
}