mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-30 22:42:29 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
commit
7bc32e67bc
@ -4,6 +4,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -117,10 +118,17 @@ type ApiInfo struct {
|
|||||||
|
|
||||||
type FuncInfo struct {
|
type FuncInfo struct {
|
||||||
FuncName string
|
FuncName string
|
||||||
Args map[string]interface{}
|
Args Args
|
||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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{}) {
|
func SetContextInfo(ctx context.Context, funcName string, err error, args ...interface{}) {
|
||||||
t := ctx.Value(TraceLogKey).(*ApiInfo)
|
t := ctx.Value(TraceLogKey).(*ApiInfo)
|
||||||
var funcInfo FuncInfo
|
var funcInfo FuncInfo
|
||||||
@ -155,7 +163,7 @@ func SetRpcRespInfo(ctx context.Context, funcName string, resp string) {
|
|||||||
|
|
||||||
func SetSuccess(ctx context.Context, funcName string, data interface{}) {
|
func SetSuccess(ctx context.Context, funcName string, data interface{}) {
|
||||||
SetContextInfo(ctx, funcName, nil, "data", data)
|
SetContextInfo(ctx, funcName, nil, "data", data)
|
||||||
ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": data})
|
ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "errDtl": "", "data": data})
|
||||||
}
|
}
|
||||||
|
|
||||||
func argsHandle(args []interface{}, fields map[string]interface{}) {
|
func argsHandle(args []interface{}, fields map[string]interface{}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user