diff --git a/log/value.go b/log/value.go index 5aceffeb5..66f0b81c0 100644 --- a/log/value.go +++ b/log/value.go @@ -32,6 +32,10 @@ func Caller(depth int) Valuer { return func(context.Context) interface{} { _, file, line, _ := runtime.Caller(depth) idx := strings.LastIndexByte(file, '/') + if idx == -1 { + return file[idx+1:] + ":" + strconv.Itoa(line) + } + idx = strings.LastIndexByte(file[:idx], '/') return file[idx+1:] + ":" + strconv.Itoa(line) } }