diff --git a/database.go b/database.go index 4550771..5a29a0f 100644 --- a/database.go +++ b/database.go @@ -89,11 +89,12 @@ func defaultLogger(sql string, durationNano int64) { var file string var line int var ok bool - var stackDepth = 2 - for _, file, line, ok = runtime.Caller(stackDepth); ok; stackDepth++ { + for i := 0; i < 16; i++ { + _, file, line, ok = runtime.Caller(i) // `!strings.HasPrefix(file, srcPrefix)` jump out when using sqlingo as dependent package // `strings.HasSuffix(file, "_test.go")` jump out when executing unit test cases - if !strings.HasPrefix(file, srcPrefix) || strings.HasSuffix(file, "_test.go") { + // `!ok` this is so terrible for something unexpected happened + if !ok || !strings.HasPrefix(file, srcPrefix) || strings.HasSuffix(file, "_test.go") { break } }