Files
log/entry/caller.go
andrey1s 615c6b7cd6
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
update golang
2022-03-13 11:56:49 +03:00

23 lines
315 B
Go

package entry
import (
"path/filepath"
"runtime"
"strconv"
)
func Caller(depth int, full bool) string {
const offset = 4
_, file, line, has := runtime.Caller(depth + offset)
if !has {
file, line = "???", 0
}
if !full && has {
file = filepath.Base(file)
}
return file + ":" + strconv.Itoa(line)
}