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