pull/1053/head
chenzhihui 3 years ago
parent 7340fecf27
commit 0e6c53fda9
  1. 16
      log/value.go

@ -33,15 +33,13 @@ func Value(ctx context.Context, v interface{}) interface{} {
func Caller(depth int) Valuer { func Caller(depth int) Valuer {
return func(context.Context) interface{} { return func(context.Context) interface{} {
_, file, line, _ := runtime.Caller(depth) _, file, line, _ := runtime.Caller(depth)
for true { if strings.LastIndex(file, "/log/helper.go") > 0 {
h := strings.LastIndex(file, "/log/helper.go") depth++
f := strings.LastIndex(file, "/log/filter.go") _, file, line, _ = runtime.Caller(depth)
if h > 0 || f > 0 { }
depth++ if strings.LastIndex(file, "/log/filter.go") > 0 {
_, file, line, _ = runtime.Caller(depth) depth++
} else { _, file, line, _ = runtime.Caller(depth)
break
}
} }
idx := strings.LastIndexByte(file, '/') idx := strings.LastIndexByte(file, '/')
return file[idx+1:] + ":" + strconv.Itoa(line) return file[idx+1:] + ":" + strconv.Itoa(line)

Loading…
Cancel
Save