Verbose debug logging

This commit is contained in:
Brandon Weeks 2022-05-31 15:47:10 -07:00
parent f140874e42
commit 860baeb1c5

View file

@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
"runtime/debug"
"github.com/pkg/errors"
"github.com/smallstep/certificates/api/render"
@ -273,6 +275,8 @@ type Error struct {
// NewError creates a new Error type.
func NewError(pt ProblemType, msg string, args ...interface{}) *Error {
fmt.Fprintf(os.Stderr, msg+"\n", args...)
debug.PrintStack()
return newError(pt, errors.Errorf(msg, args...))
}
@ -298,6 +302,8 @@ func newError(pt ProblemType, err error) *Error {
// NewErrorISE creates a new ErrorServerInternalType Error.
func NewErrorISE(msg string, args ...interface{}) *Error {
fmt.Fprintf(os.Stderr, msg+"\n", args...)
debug.PrintStack()
return NewError(ErrorServerInternalType, msg, args...)
}
@ -320,6 +326,8 @@ func WrapError(typ ProblemType, err error, msg string, args ...interface{}) *Err
// WrapErrorISE shortcut to wrap an internal server error type.
func WrapErrorISE(err error, msg string, args ...interface{}) *Error {
fmt.Fprintf(os.Stderr, msg+"\n", args...)
debug.PrintStack()
return WrapError(ErrorServerInternalType, err, msg, args...)
}