From e3d6f724f4eda3fb2750d0119a187283696a8e2f Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 3 May 2024 13:13:49 +0800 Subject: [PATCH] refactor: logging and add conditional checks fix #74 - Refactor type assertion and conditional logging into a more concise format in `zap.go` - Add conditional logging based on `DefaultLevel` being `InfoLevel` in `zap.go` Signed-off-by: Bo-Yi Wu --- zap.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zap.go b/zap.go index 52738cd..34f9dbf 100644 --- a/zap.go +++ b/zap.go @@ -113,9 +113,10 @@ func GinzapWithConfig(logger ZapLogger, conf *Config) gin.HandlerFunc { logger.Error(e, fields...) } } else { - zl, ok := logger.(*zap.Logger) - if ok { + if zl, ok := logger.(*zap.Logger); ok { zl.Log(conf.DefaultLevel, "", fields...) + } else if conf.DefaultLevel == zapcore.InfoLevel { + logger.Info(path, fields...) } else { logger.Error(path, fields...) }