MCPcopy Create free account
hub / github.com/daodst/chat / callerPrettyfier

Function callerPrettyfier

internal/log.go:69–82  ·  view source on GitHub ↗

callerPrettyfier is a function that given a runtime.Frame object, will extract the calling function's name and file, and return them in a nicely formatted way

(f *runtime.Frame)

Source from the content-addressed store, hash-verified

67// extract the calling function's name and file, and return them in a nicely
68// formatted way
69func callerPrettyfier(f *runtime.Frame) (string, string) {
70 // Retrieve just the function name
71 s := strings.Split(f.Function, ".")
72 funcname := s[len(s)-1]
73
74 // Append a newline + tab to it to move the actual log content to its own line
75 funcname += "\n\t"
76
77 // Use a shortened file path which just has the filename to avoid having lots of redundant
78 // directories which contribute significantly to overall log sizes!
79 filename := fmt.Sprintf(" [%s:%d]", path.Base(f.File), f.Line)
80
81 return funcname, filename
82}
83
84// SetupPprof starts a pprof listener. We use the DefaultServeMux here because it is
85// simplest, and it gives us the freedom to run pprof on a separate port.

Callers

nothing calls this directly

Calls 1

SplitMethod · 0.80

Tested by

no test coverage detected