浏览代码

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
 // 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()))
 	ErrorLogger.Println(string(debug.Stack()))
 }
 }
 
 
@@ -26,7 +26,7 @@ type UnboundedExecutor struct {
 	cancel                context.CancelFunc
 	cancel                context.CancelFunc
 	activeGoroutinesMutex *sync.Mutex
 	activeGoroutinesMutex *sync.Mutex
 	activeGoroutines      map[string]int
 	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
 // GlobalUnboundedExecutor has the life cycle of the program itself
@@ -64,9 +64,9 @@ func (executor *UnboundedExecutor) Go(handler func(ctx context.Context)) {
 			recovered := recover()
 			recovered := recover()
 			if recovered != nil && recovered != StopSignal {
 			if recovered != nil && recovered != StopSignal {
 				if executor.HandlePanic == nil {
 				if executor.HandlePanic == nil {
-					HandlePanic(recovered, file, line, funcName)
+					HandlePanic(recovered, funcName)
 				} else {
 				} else {
-					executor.HandlePanic(recovered, file, line, funcName)
+					executor.HandlePanic(recovered, funcName)
 				}
 				}
 			}
 			}
 			executor.activeGoroutinesMutex.Lock()
 			executor.activeGoroutinesMutex.Lock()

+ 1 - 1
unbounded_executor_test.go

@@ -39,7 +39,7 @@ func ExampleUnboundedExecutor_StopAndWaitForever() {
 }
 }
 
 
 func ExampleUnboundedExecutor_Go_panic() {
 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)
 		fmt.Println(funcName)
 	}
 	}
 	executor := concurrent.NewUnboundedExecutor()
 	executor := concurrent.NewUnboundedExecutor()