File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,13 @@ import (
6
6
"context"
7
7
"errors"
8
8
"fmt"
9
+ "runtime"
9
10
"sync"
10
11
"sync/atomic"
11
12
"time"
12
13
14
+ "github.com/songzhibin97/gkit/cache/buffer"
15
+
13
16
"github.com/songzhibin97/gkit/log"
14
17
"github.com/songzhibin97/gkit/options"
15
18
"github.com/songzhibin97/gkit/timeout"
@@ -42,12 +45,15 @@ func (g *Goroutine) _go() {
42
45
// recover 避免野生goroutine panic后主程退出
43
46
defer func () {
44
47
if err := recover (); err != nil {
48
+ buf := buffer .GetBytes (64 << 10 )
49
+ n := runtime .Stack (* buf , false )
50
+ defer buffer .PutBytes (buf )
45
51
// recover panic
46
52
if g .logger == nil {
47
- fmt .Println ("recover go func, error :" , err )
53
+ fmt .Println ("recover go func, stack :" , ( * buf )[: n ] )
48
54
return
49
55
}
50
- g .logger .Log (log .LevelError , "Panic" , err )
56
+ g .logger .Log (log .LevelError , "Panic stack: " , ( * buf )[: n ] )
51
57
return
52
58
}
53
59
}()
You can’t perform that action at this time.
0 commit comments