improved api error handling

This commit is contained in:
yusing
2025-01-05 00:02:31 +08:00
parent 0e886f5ddf
commit 55134c8426
4 changed files with 17 additions and 20 deletions

View File

@@ -8,9 +8,10 @@ import (
)
func reqLogger(r *http.Request, level zerolog.Level) *zerolog.Event {
return logging.WithLevel(level).Str("module", "api").
Str("method", r.Method).
Str("path", r.RequestURI)
return logging.WithLevel(level).
Str("module", "api").
Str("remote", r.RemoteAddr).
Str("uri", r.Method+" "+r.RequestURI)
}
func LogError(r *http.Request) *zerolog.Event { return reqLogger(r, zerolog.ErrorLevel) }