From 79c40ab8a1afcf9d54f8b33ae78f9ec4db499eef Mon Sep 17 00:00:00 2001 From: miaolz123 Date: Wed, 1 Jul 2020 17:29:55 +0800 Subject: [PATCH] feat: update iris logger --- iriser/iriser.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iriser/iriser.go b/iriser/iriser.go index bebdeaa..ea021aa 100644 --- a/iriser/iriser.go +++ b/iriser/iriser.go @@ -37,12 +37,15 @@ func Register(r router.Party, h interface{}) { } } -func NewLogger() iris.Handler { +func NewLogger(ignore func(method, path string) bool) iris.Handler { cfg := logger.DefaultConfig() cfg.LogFuncCtx = func(ctx iris.Context, latency time.Duration) { if ctx.Method() == iris.MethodOptions { return } + if ignore != nil && ignore(ctx.Method(), ctx.Path()) { + return + } fields := log.F{ "method": ctx.Method(), "path": ctx.Path(),