tweak caller skip count

This commit is contained in:
kkocdko 2024-04-21 04:22:09 +08:00 committed by GitHub
parent 869b503c9f
commit 143e758bec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,8 +33,8 @@ func sourceDir(file string) string {
// FileWithLineNum return the file name and line number of the current file
func FileWithLineNum() string {
pcs := [13]uintptr{}
// the second caller usually from gorm internal, so start from 2
len := runtime.Callers(2, pcs[:])
// the third caller usually from gorm internal
len := runtime.Callers(3, pcs[:])
frames := runtime.CallersFrames(pcs[:len])
for i := 0; i < len; i++ {
// second return value is "more", not "ok"