Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode

# Conflicts:
#	internal/api_to_rpc/api.go
test-errcode
wangchuxiao 2 years ago
parent 1a32b49662
commit ff524b0ee7

@ -2,7 +2,6 @@ package trace_log
import ( import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -43,28 +42,28 @@ func GetOperationID(ctx context.Context) string {
return ctx.Value(TraceLogKey).(*ApiInfo).OperationID return ctx.Value(TraceLogKey).(*ApiInfo).OperationID
} }
func ShowLog(ctx context.Context) { //func ShowLog(ctx context.Context) {
t := ctx.Value(TraceLogKey).(*ApiInfo) // t := ctx.Value(TraceLogKey).(*ApiInfo)
if ctx.Value(TraceLogKey).(*ApiInfo).GinCtx != nil { // if ctx.Value(TraceLogKey).(*ApiInfo).GinCtx != nil {
log.Info(t.OperationID, "api: ", t.ApiName) // log.Info(t.OperationID, "api: ", t.ApiName)
} else { // } else {
log.Info(t.OperationID, "rpc: ", t.ApiName) // log.Info(t.OperationID, "rpc: ", t.ApiName)
} // }
for _, v := range *t.Funcs { // for _, v := range *t.Funcs {
if v.Err != nil { // if v.Err != nil {
log.Error(t.OperationID, "func: ", v.FuncName, " args: ", v.Args, v.Err.Error()) // log.Error(t.OperationID, "func: ", v.FuncName, " args: ", v.Args, v.Err.Error())
} else { // } else {
switch v.LogLevel { // switch v.LogLevel {
case logrus.InfoLevel: // case logrus.InfoLevel:
log.Info(t.OperationID, "func: ", v.FuncName, " args: ", v.Args) // log.Info(t.OperationID, "func: ", v.FuncName, " args: ", v.Args)
case logrus.DebugLevel: // case logrus.DebugLevel:
log.Debug(t.OperationID, "func: ", v.FuncName, " args: ", v.Args) // log.Debug(t.OperationID, "func: ", v.FuncName, " args: ", v.Args)
case logrus.WarnLevel: // case logrus.WarnLevel:
log.Debug(t.OperationID, "func: ", v.FuncName, " args: ", v.Args) // log.Debug(t.OperationID, "func: ", v.FuncName, " args: ", v.Args)
} // }
} // }
} // }
} //}
func WriteErrorResponse(ctx context.Context, funcName string, err error, args ...interface{}) { func WriteErrorResponse(ctx context.Context, funcName string, err error, args ...interface{}) {
SetCtxInfo(ctx, funcName, err, args) SetCtxInfo(ctx, funcName, err, args)

Loading…
Cancel
Save