Files
gf/util/gutil/gutil_debug.go

29 lines
770 B
Go

// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gutil
import (
"fmt"
"github.com/gogf/gf/internal/debug"
)
const (
gFILTER_KEY = "/gf/util/gutil/gutil"
)
// PrintStack prints to standard error the stack trace returned by runtime.Stack.
func PrintStack(skip ...int) {
fmt.Print(Stack(skip...))
}
// Stack returns a formatted stack trace of the goroutine that calls it.
// It calls runtime.Stack with a large enough buffer to capture the entire trace.
func Stack(skip ...int) string {
return debug.StackWithFilter(gFILTER_KEY, skip...)
}