From 0e6c53fda997a3f7e85fa636b8bf5281c6b42ae3 Mon Sep 17 00:00:00 2001 From: chenzhihui Date: Mon, 14 Jun 2021 10:25:59 +0800 Subject: [PATCH] fix --- log/value.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/log/value.go b/log/value.go index 175f9d2d1..762d84804 100644 --- a/log/value.go +++ b/log/value.go @@ -33,15 +33,13 @@ func Value(ctx context.Context, v interface{}) interface{} { func Caller(depth int) Valuer { return func(context.Context) interface{} { _, file, line, _ := runtime.Caller(depth) - for true { - h := strings.LastIndex(file, "/log/helper.go") - f := strings.LastIndex(file, "/log/filter.go") - if h > 0 || f > 0 { - depth++ - _, file, line, _ = runtime.Caller(depth) - } else { - break - } + if strings.LastIndex(file, "/log/helper.go") > 0 { + depth++ + _, file, line, _ = runtime.Caller(depth) + } + if strings.LastIndex(file, "/log/filter.go") > 0 { + depth++ + _, file, line, _ = runtime.Caller(depth) } idx := strings.LastIndexByte(file, '/') return file[idx+1:] + ":" + strconv.Itoa(line)