Skip to content

Commit

Permalink
do not expose func file and line
Browse files Browse the repository at this point in the history
  • Loading branch information
taowen committed Mar 1, 2018
1 parent b889e4d commit 938152c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions unbounded_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

// HandlePanic logs goroutine panic by default
var HandlePanic = func(recovered interface{}, file string, line int, funcName string) {
ErrorLogger.Println(fmt.Sprintf("%s defined at %s:%v panic: %v", funcName, file, line, recovered))
var HandlePanic = func(recovered interface{}, funcName string) {
ErrorLogger.Println(fmt.Sprintf("%s panic: %v", funcName, recovered))
ErrorLogger.Println(string(debug.Stack()))
}

Expand All @@ -26,7 +26,7 @@ type UnboundedExecutor struct {
cancel context.CancelFunc
activeGoroutinesMutex *sync.Mutex
activeGoroutines map[string]int
HandlePanic func(recovered interface{}, file string, line int, funcName string)
HandlePanic func(recovered interface{}, funcName string)
}

// GlobalUnboundedExecutor has the life cycle of the program itself
Expand Down Expand Up @@ -64,9 +64,9 @@ func (executor *UnboundedExecutor) Go(handler func(ctx context.Context)) {
recovered := recover()
if recovered != nil && recovered != StopSignal {
if executor.HandlePanic == nil {
HandlePanic(recovered, file, line, funcName)
HandlePanic(recovered, funcName)
} else {
executor.HandlePanic(recovered, file, line, funcName)
executor.HandlePanic(recovered, funcName)
}
}
executor.activeGoroutinesMutex.Lock()
Expand Down
2 changes: 1 addition & 1 deletion unbounded_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func ExampleUnboundedExecutor_StopAndWaitForever() {
}

func ExampleUnboundedExecutor_Go_panic() {
concurrent.HandlePanic = func(recovered interface{}, file string, line int, funcName string) {
concurrent.HandlePanic = func(recovered interface{}, funcName string) {
fmt.Println(funcName)
}
executor := concurrent.NewUnboundedExecutor()
Expand Down

0 comments on commit 938152c

Please sign in to comment.