mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-05 09:46:49 +08:00
1
This commit is contained in:
parent
7bc32e67bc
commit
5e020bb514
@ -41,7 +41,7 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
|
||||
}
|
||||
ctx = trace_log.NewRpcCtx(ctx, funcName, operationID)
|
||||
defer trace_log.ShowLog(ctx)
|
||||
trace_log.SetContextInfo(ctx, funcName, err, "opUserID", opUserID, "rpcReq", req.(interface{ String() string }).String())
|
||||
trace_log.SetContextInfo(ctx, funcName, err, "opUserID", opUserID, "rpcReq", rpcString(req))
|
||||
resp, err = handler(ctx, req)
|
||||
if err != nil {
|
||||
trace_log.SetContextInfo(ctx, funcName, err)
|
||||
@ -58,7 +58,7 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
|
||||
}
|
||||
return nil, sta.Err()
|
||||
}
|
||||
trace_log.SetContextInfo(ctx, funcName, nil, "rpcResp", resp.(interface{ String() string }).String())
|
||||
trace_log.SetContextInfo(ctx, funcName, nil, "rpcResp", rpcString(resp))
|
||||
return
|
||||
}
|
||||
|
||||
@ -77,3 +77,10 @@ func RpcClientInterceptor(ctx context.Context, method string, req, reply interfa
|
||||
md := metadata.Pairs("operationID", operationID, "opUserID", opUserID)
|
||||
return invoker(metadata.NewOutgoingContext(ctx, md), method, req, reply, cc, opts...)
|
||||
}
|
||||
|
||||
func rpcString(v interface{}) string {
|
||||
if s, ok := v.(interface{ String() string }); ok {
|
||||
return s.String()
|
||||
}
|
||||
return fmt.Sprintf("%+v", v)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user