From 5cc92860a6a034a296af12a0c779b39d94ce5b29 Mon Sep 17 00:00:00 2001 From: Yang Shi Date: Sun, 3 Nov 2019 07:08:54 +0800 Subject: [PATCH] improve the log of panic recovering (#906) --- grpc.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grpc.go b/grpc.go index e037a0d..9b66428 100644 --- a/grpc.go +++ b/grpc.go @@ -7,6 +7,7 @@ import ( "fmt" "net" "reflect" + "runtime/debug" "sort" "strconv" "strings" @@ -340,7 +341,8 @@ func (g *grpcServer) processRequest(stream grpc.ServerStream, service *service, fn := func(ctx context.Context, req server.Request, rsp interface{}) error { defer func() { if r := recover(); r != nil { - log.Logf("handler %s panic recovered, err: %s", mtype.method.Name, r) + log.Log("panic recovered: ", r) + log.Logf(string(debug.Stack())) } }() returnValues = function.Call([]reflect.Value{service.rcvr, mtype.prepareContext(ctx), reflect.ValueOf(argv.Interface()), reflect.ValueOf(rsp)})