Skip to content

Commit

Permalink
fix: ignore .gen.go suffix in logger to get the real caller when usin…
Browse files Browse the repository at this point in the history
…g gen go-gorm#6697
  • Loading branch information
0xJacky committed Jan 8, 2024
1 parent 87decce commit 57d6553
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func FileWithLineNum() string {
// the second caller usually from gorm internal, so set i start from 2
for i := 2; i < 15; i++ {
_, file, line, ok := runtime.Caller(i)
if ok && (!strings.HasPrefix(file, gormSourceDir) || strings.HasSuffix(file, "_test.go")) {
if ok && (!strings.HasPrefix(file, gormSourceDir) || strings.HasSuffix(file, "_test.go")) &&
!strings.HasSuffix(file, ".gen.go") {
return file + ":" + strconv.FormatInt(int64(line), 10)
}
}
Expand Down

0 comments on commit 57d6553

Please sign in to comment.