优化recover日志

This commit is contained in:
duanhf2012
2021-07-26 17:45:32 +08:00
parent a6ea25bba0
commit be98b62979
5 changed files with 15 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package rpc
import (
"container/list"
"errors"
"fmt"
"github.com/duanhf2012/origin/log"
"github.com/duanhf2012/origin/network"
"github.com/duanhf2012/origin/util/timer"
@@ -261,7 +262,8 @@ func (client *Client) Run(){
if r := recover(); r != nil {
buf := make([]byte, 4096)
l := runtime.Stack(buf, false)
log.SError("core dump info:",r,":", string(buf[:l]))
errString := fmt.Sprint(r)
log.SError("core dump info[",errString,"]\n", string(buf[:l]))
}
}()

View File

@@ -194,7 +194,8 @@ func (handler *RpcHandler) HandlerRpcResponseCB(call *Call){
if r := recover(); r != nil {
buf := make([]byte, 4096)
l := runtime.Stack(buf, false)
log.SError("core dump info:",r,":",string(buf[:l]))
errString := fmt.Sprint(r)
log.SError("core dump info[",errString,"]\n",string(buf[:l]))
}
}()
@@ -215,7 +216,8 @@ func (handler *RpcHandler) HandlerRpcRequest(request *RpcRequest) {
if r := recover(); r != nil {
buf := make([]byte, 4096)
l := runtime.Stack(buf, false)
log.SError("Handler Rpc ",request.RpcRequestData.GetServiceMethod()," Core dump info:",r,":",string(buf[:l]))
errString := fmt.Sprint(r)
log.SError("Handler Rpc ",request.RpcRequestData.GetServiceMethod()," Core dump info[",errString,"]\n",string(buf[:l]))
rpcErr := RpcError("call error : core dumps")
if request.requestHandle!=nil {
request.requestHandle(nil,rpcErr)