Преглед изворни кода

do not expose func file and line

Tao Wen пре 7 година
родитељ
комит
938152ca6a
2 измењених фајлова са 6 додато и 6 уклоњено
  1. 5 5
      unbounded_executor.go
  2. 1 1
      unbounded_executor_test.go

+ 5 - 5
unbounded_executor.go

@@ -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()))
 }
 
@@ -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
@@ -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()

+ 1 - 1
unbounded_executor_test.go

@@ -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()