MCPcopy
hub / github.com/uber-go/zap / Take

Function Take

internal/stacktrace/stack.go:135–145  ·  view source on GitHub ↗

Take returns a string representation of the current stacktrace. skip is the number of frames to skip before recording the stack trace. skip=0 identifies the caller of Take.

(skip int)

Source from the content-addressed store, hash-verified

133// skip is the number of frames to skip before recording the stack trace.
134// skip=0 identifies the caller of Take.
135func Take(skip int) string {
136 stack := Capture(skip+1, Full)
137 defer stack.Free()
138
139 buffer := bufferpool.Get()
140 defer buffer.Free()
141
142 stackfmt := NewFormatter(buffer)
143 stackfmt.FormatStack(stack)
144 return buffer.String()
145}
146
147// Formatter formats a stack trace into a readable string representation.
148type Formatter struct {

Callers 10

TestStackFieldFunction · 0.92
TestStackSkipFieldFunction · 0.92
StackSkipFunction · 0.92
HandleMethod · 0.92
TestTakeFunction · 0.85
TestTakeWithSkipFunction · 0.85
TestTakeDeepStackFunction · 0.85
BenchmarkTakeFunction · 0.85

Calls 6

FormatStackMethod · 0.95
CaptureFunction · 0.85
NewFormatterFunction · 0.85
FreeMethod · 0.45
GetMethod · 0.45
StringMethod · 0.45

Tested by 8

TestStackFieldFunction · 0.74
TestStackSkipFieldFunction · 0.74
TestTakeFunction · 0.68
TestTakeWithSkipFunction · 0.68
TestTakeDeepStackFunction · 0.68
BenchmarkTakeFunction · 0.68