Files
log/entry/caller.go
andrey 7570ade82a
All checks were successful
continuous-integration/drone/push Build is passing
upddate caller write method (#5)
Co-authored-by: andrey1s <andrey@4devs.pro>
Reviewed-on: #5
Co-authored-by: andrey <andrey@4devs.io>
Co-committed-by: andrey <andrey@4devs.io>
2022-03-14 09:58:23 +03:00

23 lines
315 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)
}