MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / Getcaller

Function Getcaller

utils/log/log.go:16–38  ·  view source on GitHub ↗
(msg string)

Source from the content-addressed store, hash-verified

14}
15
16func Getcaller(msg string) string {
17 pc, _, _, ok := runtime.Caller(2)
18 if !ok {
19 return "[unkcal] " + msg
20 }
21 fp := runtime.FuncForPC(pc)
22 sb := strings.Builder{}
23 sb.WriteByte('[')
24 if fp == nil {
25 sb.WriteString(" unkfun]")
26 sb.WriteString(msg)
27 return sb.String()
28 }
29 n := fp.Name()
30 i := strings.LastIndex(n, "/")
31 if i > 0 && i < len(n) {
32 n = n[i+1:]
33 }
34 sb.WriteString(n)
35 sb.WriteString("] ")
36 sb.WriteString(msg)
37 return sb.String()
38}

Callers 7

warningMethod · 0.92
warninglnMethod · 0.92
errorMethod · 0.92
errorlnMethod · 0.92
debugMethod · 0.92
debuglnMethod · 0.92
dumpMethod · 0.92

Calls 2

StringMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected