Skip to content

Commit

Permalink
Try different approach to omit the gorm files
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jul 7, 2022
1 parent 968d4b3 commit 9dbee70
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,12 @@ func displayLog(level LogLevel, stackLevel int, message string, params ...interf
// Copied method in order to not make GORM a dependency of the project for this tiny utility method
func fileWithLineNum() string {
// the first & second caller usually from gorm internal, so set index start from 3
for i := 3; i < 15; i++ {
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, "callback.go") ||
strings.HasSuffix(file, "finisher_api.go")) {
return file + ":" + strconv.FormatInt(int64(line), 10)
}
}
Expand Down

0 comments on commit 9dbee70

Please sign in to comment.