From e2dfb3e5ad2323c031c1a834db209a1f49b0fee3 Mon Sep 17 00:00:00 2001 From: yuguojian <18126816215> Date: Thu, 10 Jul 2025 10:18:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=8F=82=E6=95=B0=E5=92=8C?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E8=BD=AC=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- log/log.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/log/log.go b/log/log.go index b587d2f..4bd9711 100644 --- a/log/log.go +++ b/log/log.go @@ -99,17 +99,13 @@ func HandleLog(log *LogInfo) { log.Timestamp = carbon.Now().Timestamp() // 处理 Param // 处理 Param - if log.Param != nil { - log.Param = processValue(log.Param) - } + log.Param = processValue(log.Param) // 处理 Result - if log.Result != nil { - if _, ok := log.Result.(error); ok { - log.ErrStr = fmt.Sprintf("%+v", log.Result) - log.Result = nil - } else { - log.Result = processValue(log.Result) - } + if _, ok := log.Result.(error); ok { + log.ErrStr = fmt.Sprintf("%+v", log.Result) + log.Result = struct{}{} + } else { + log.Result = processValue(log.Result) } } @@ -164,6 +160,9 @@ func (l *LogInfo) ZapCommonHandelResult(logger *zap.Logger, result interface{}, } func processValue(value interface{}) interface{} { + if value == nil { + return struct{}{} + } kind := reflect.TypeOf(value).Kind() switch kind { case reflect.Map, reflect.Slice, reflect.Array, reflect.Struct: