improve debugging feature

This commit is contained in:
John Guo
2021-12-04 23:07:54 +08:00
parent 8586f31e03
commit 0e3a8576b4
6 changed files with 21 additions and 38 deletions

View File

@ -14,8 +14,6 @@ import (
"reflect"
"runtime"
"strings"
"github.com/gogf/gf/v2/internal/utils"
)
const (
@ -35,7 +33,7 @@ func init() {
goRootForFilter = strings.Replace(goRootForFilter, "\\", "/", -1)
}
// Initialize internal package variable: selfPath.
selfPath, _ := exec.LookPath(os.Args[0])
selfPath, _ = exec.LookPath(os.Args[0])
if selfPath != "" {
selfPath, _ = filepath.Abs(selfPath)
}
@ -69,7 +67,7 @@ func CallerWithFilter(filter string, skip ...int) (function string, path string,
pc, file, line, ok = runtime.Caller(i)
}
if ok {
function := ""
function = ""
if fn := runtime.FuncForPC(pc); fn == nil {
function = "unknown"
} else {
@ -102,14 +100,8 @@ func callerFromIndex(filters []string) (pc uintptr, file string, line int, index
if filtered {
continue
}
if !utils.IsDebugEnabled() {
if strings.Contains(file, utils.StackFilterKeyForGoFrame) {
continue
}
} else {
if strings.Contains(file, stackFilterKey) {
continue
}
if strings.Contains(file, stackFilterKey) {
continue
}
if index > 0 {
index--

View File

@ -11,8 +11,6 @@ import (
"fmt"
"runtime"
"strings"
"github.com/gogf/gf/v2/internal/utils"
)
// PrintStack prints to standard error the stack trace returned by runtime.Stack.
@ -82,14 +80,8 @@ func StackWithFilters(filters []string, skip ...int) string {
continue
}
if !utils.IsDebugEnabled() {
if strings.Contains(file, utils.StackFilterKeyForGoFrame) {
continue
}
} else {
if strings.Contains(file, stackFilterKey) {
continue
}
if strings.Contains(file, stackFilterKey) {
continue
}
if fn := runtime.FuncForPC(pc); fn == nil {