From 89fd5d273b241d8b0664efb9b2009026abea8c27 Mon Sep 17 00:00:00 2001 From: orgin Date: Fri, 15 Jul 2022 20:25:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=87=AA=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E5=BC=80=E5=8D=8F=E7=A8=8B=E5=87=BD=E6=95=B0GoRecover?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/coroutine/coroutine.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/coroutine/coroutine.go b/util/coroutine/coroutine.go index bb99974..88b6811 100644 --- a/util/coroutine/coroutine.go +++ b/util/coroutine/coroutine.go @@ -2,6 +2,7 @@ package coroutine import ( "fmt" + "github.com/duanhf2012/origin/log" "reflect" "runtime/debug" ) @@ -12,10 +13,11 @@ func F(callback interface{},recoverNum int, args ...interface{}) { var coreInfo string coreInfo = string(debug.Stack()) coreInfo += "\n" + fmt.Sprintf("Core information is %v\n", r) - fmt.Print(coreInfo) - - if recoverNum==-1 ||recoverNum-1 >= 0 { + log.SError(coreInfo) + if recoverNum > 0{ recoverNum -= 1 + } + if recoverNum == -1 || recoverNum > 0 { go F(callback,recoverNum, args...) } }