fix: nolog reverse

master
Evan Chen 2021-11-04 02:15:45 +08:00
parent 49c5239928
commit 337d64b13b
1 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ func New() *kserver {
}
k := &kserver{
l: l,
nolog: func(r *http.Request) bool { return true },
nolog: func(r *http.Request) bool { return false },
}
return k
}
@ -95,7 +95,7 @@ func (k *kserver) catch(rw *responseWriter, r *http.Request) {
k.l.ErrorF(log.H{"Status": rw.StatueCode, "IP": GetIP(r), "Method": r.Method, "URL": r.URL.Path, "Agent": r.Header.Get("User-Agent")}, ex)
} else if rw.StatueCode >= 500 {
k.l.ErrorF(log.H{"Status": rw.StatueCode, "IP": GetIP(r), "Method": r.Method, "URL": r.URL.Path, "Agent": r.Header.Get("User-Agent")}, rw.err)
} else if k.nolog != nil && k.nolog(r) {
} else if k.nolog == nil || !k.nolog(r) {
k.l.InfoF(log.H{"Status": rw.StatueCode, "IP": GetIP(r), "Method": r.Method, "URL": r.URL.Path, "Agent": r.Header.Get("User-Agent")})
}
}