From edbf1a3b63564cfb7314448d59950898b849e801 Mon Sep 17 00:00:00 2001 From: benqi Date: Sat, 23 Jul 2022 12:15:37 +0800 Subject: [PATCH] fix: fix switch doesn't work bug (#2183) --- .../serverinterceptors/statinterceptor.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/zrpc/internal/serverinterceptors/statinterceptor.go b/zrpc/internal/serverinterceptors/statinterceptor.go index a0997878..05cd04b4 100644 --- a/zrpc/internal/serverinterceptors/statinterceptor.go +++ b/zrpc/internal/serverinterceptors/statinterceptor.go @@ -64,15 +64,15 @@ func logDuration(ctx context.Context, method string, req interface{}, duration t } else { logger.Infof("%s - %s - %s", addr, method) } - } - - content, err := json.Marshal(req) - if err != nil { - logx.WithContext(ctx).Errorf("%s - %s", addr, err.Error()) - } else if duration > slowThreshold.Load() { - logger.Slowf("[RPC] slowcall - %s - %s - %s", - addr, method, string(content)) } else { - logger.Infof("%s - %s - %s", addr, method, string(content)) + content, err := json.Marshal(req) + if err != nil { + logx.WithContext(ctx).Errorf("%s - %s", addr, err.Error()) + } else if duration > slowThreshold.Load() { + logger.Slowf("[RPC] slowcall - %s - %s - %s", + addr, method, string(content)) + } else { + logger.Infof("%s - %s - %s", addr, method, string(content)) + } } }