mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 08:10:28 +00:00
normalize http method spacing for consistent logs
This commit is contained in:
parent
1148690440
commit
b09f08926f
1 changed files with 9 additions and 2 deletions
|
@ -67,6 +67,13 @@ func SugarLogger(log zerolog.Logger) server.Middleware {
|
|||
}
|
||||
bold := func(s string) string { return "\033[1m" + s + "\033[0m" }
|
||||
|
||||
atLeast6 := func(s string) string {
|
||||
for len(s) <= 6 {
|
||||
s += " "
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
return func(next server.Handler) server.Handler {
|
||||
return server.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {
|
||||
|
||||
|
@ -78,9 +85,9 @@ func SugarLogger(log zerolog.Logger) server.Middleware {
|
|||
|
||||
log.Info().
|
||||
Str("trace_id", server.GetTraceID(r.Context())).
|
||||
Msgf("%s %s %s",
|
||||
Msgf("%s %s %s",
|
||||
bold(fmtCode(record.Status)),
|
||||
bold(orange(""+r.Method+"")),
|
||||
bold(orange(atLeast6(r.Method))),
|
||||
aqua(url),
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue