Skip to content

Commit

Permalink
Revert "iterate caller stack more stronger"
Browse files Browse the repository at this point in the history
This reverts commit 13387ac.
  • Loading branch information
VarusHsu committed Feb 18, 2024
1 parent 13387ac commit 5d8d7fc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 5d8d7fc

Please sign in to comment.