stacktrace
v1.28.0
Documentation
pkg.go.dev ↗Package stacktrace provides support for gathering stack traces efficiently.
Functions
Take
func Take(skip int) string
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.
Types
Depth
type Depth int
Depth specifies how deep of a stack trace should be captured.
First (2 declarations)
const ( // First captures only the first frame. First Depth = iota // Full captures the entire call stack, allocating more // storage for it if needed. Full )
Formatter
type Formatter struct {
// contains filtered or unexported fields
}
Formatter formats a stack trace into a readable string representation.
NewFormatter
func NewFormatter(b *buffer.Buffer) Formatter
NewFormatter builds a new Formatter.
Formatter.FormatFrame
func (sf *Formatter) FormatFrame(frame runtime.Frame)
FormatFrame formats the given frame.
Formatter.FormatStack
func (sf *Formatter) FormatStack(stack *Stack)
FormatStack formats all remaining frames in the provided stacktrace -- minus the final runtime.main/runtime.goexit frame.
Stack
type Stack struct {
// contains filtered or unexported fields
}
Stack is a captured stack trace.
Capture
func Capture(skip int, depth Depth) *Stack
Capture captures a stack trace of the specified depth, skipping the provided number of frames. skip=0 identifies the caller of Capture.
The caller must call Free on the returned stacktrace after using it.
Stack.Count
func (st *Stack) Count() int
Count reports the total number of frames in this stacktrace. Count DOES NOT change as Next is called.
Stack.Free
func (st *Stack) Free()
Free releases resources associated with this stacktrace and returns it back to the pool.
Stack.Next
func (st *Stack) Next() (_ runtime.Frame, more bool)
Next returns the next frame in the stack trace, and a boolean indicating whether there are more after it.