From 9bc659e8f0483a471c0cf4dcf878dcd22c7a6d84 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 12 Jan 2023 11:14:37 +0800 Subject: [PATCH] db --- pkg/common/trace_log/ctx.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/common/trace_log/ctx.go b/pkg/common/trace_log/ctx.go index 23ce182fb..142bbd7dc 100644 --- a/pkg/common/trace_log/ctx.go +++ b/pkg/common/trace_log/ctx.go @@ -123,6 +123,22 @@ type FuncInfo struct { type Args map[string]interface{} +func (a Args) String() string { + var s string + var hasElement bool + for k, v := range a { + if !hasElement { + s += "{" + hasElement = true + } + s += fmt.Sprintf("%s:%d", k, v) + } + if hasElement { + s += "}" + } + return s +} + func SetContextInfo(ctx context.Context, funcName string, err error, args ...interface{}) { t := ctx.Value(TraceLogKey).(*ApiInfo) var funcInfo FuncInfo