From 337d64b13b436801e38f52570a08dc6204ffbd28 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Thu, 4 Nov 2021 02:15:45 +0800 Subject: [PATCH] fix: nolog reverse --- kserver.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kserver.go b/kserver.go index 77b92cb..19332f4 100644 --- a/kserver.go +++ b/kserver.go @@ -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")}) } }