From 6808d734b40073f46a2c5a85f6572abe57d11009 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 12 Jan 2023 10:55:07 +0800 Subject: [PATCH 1/5] db --- pkg/common/trace_log/ctx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/trace_log/ctx.go b/pkg/common/trace_log/ctx.go index 87ffed4bf..73e4a9606 100644 --- a/pkg/common/trace_log/ctx.go +++ b/pkg/common/trace_log/ctx.go @@ -124,7 +124,7 @@ type FuncInfo struct { type Args map[string]interface{} -func (a *Args) String() string { +func (a Args) String() string { bytes, _ := json.Marshal(a) return string(bytes) } From db51b597da7c0e6011a8be2a55abfdc30798d55b Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 12 Jan 2023 11:09:08 +0800 Subject: [PATCH 2/5] db --- pkg/common/trace_log/ctx.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/common/trace_log/ctx.go b/pkg/common/trace_log/ctx.go index 73e4a9606..23ce182fb 100644 --- a/pkg/common/trace_log/ctx.go +++ b/pkg/common/trace_log/ctx.go @@ -4,7 +4,6 @@ import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" "context" - "encoding/json" "google.golang.org/grpc/status" "strings" @@ -124,11 +123,6 @@ type FuncInfo struct { type Args map[string]interface{} -func (a Args) String() string { - bytes, _ := json.Marshal(a) - return string(bytes) -} - func SetContextInfo(ctx context.Context, funcName string, err error, args ...interface{}) { t := ctx.Value(TraceLogKey).(*ApiInfo) var funcInfo FuncInfo From 9bc659e8f0483a471c0cf4dcf878dcd22c7a6d84 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 12 Jan 2023 11:14:37 +0800 Subject: [PATCH 3/5] 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 From 6ee06ded3feb89dbad12992b6fb737caa95aaad7 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 12 Jan 2023 11:19:25 +0800 Subject: [PATCH 4/5] db --- pkg/common/trace_log/ctx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/trace_log/ctx.go b/pkg/common/trace_log/ctx.go index 142bbd7dc..eccf3fb19 100644 --- a/pkg/common/trace_log/ctx.go +++ b/pkg/common/trace_log/ctx.go @@ -131,7 +131,7 @@ func (a Args) String() string { s += "{" hasElement = true } - s += fmt.Sprintf("%s:%d", k, v) + s += fmt.Sprintf("%s:%v", k, v) } if hasElement { s += "}" From 47766a2c2cf4ae6e92b21f33ab5ef3bd1918c499 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 12 Jan 2023 11:23:07 +0800 Subject: [PATCH 5/5] db --- pkg/common/trace_log/ctx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/trace_log/ctx.go b/pkg/common/trace_log/ctx.go index eccf3fb19..db264491e 100644 --- a/pkg/common/trace_log/ctx.go +++ b/pkg/common/trace_log/ctx.go @@ -131,7 +131,7 @@ func (a Args) String() string { s += "{" hasElement = true } - s += fmt.Sprintf("%s:%v", k, v) + s += fmt.Sprintf("%s: %v", k, v) } if hasElement { s += "}"