Files
log/entry/caller.go
andrey 9f8f38e43f
All checks were successful
Go Action / goaction (push) Successful in 19m15s
add lint action (#19)
Reviewed-on: #19
2025-12-23 22:01:14 +03:00

24 lines
316 B
Go

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