debug

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 9 Imported by: 21

Documentation

Index

Constants

View Source
const DefaultMaxSize = 1024

DefaultMaxSize is the default maximum size for a logged request or result value in bytes.

Variables

This section is empty.

Functions

func FormatJSON

func FormatJSON(ctx context.Context, v interface{}) string

FormatJSON returns a function that formats the given value as JSON.

func LogPayloads

func LogPayloads(opts ...LogPayloadsOption) func(goa.Endpoint) goa.Endpoint

LogPayloads returns a Goa endpoint middleware that logs request payloads and response results using debug log entries.

Note: this middleware marshals the request and response data using the standard JSON marshaller. It only marshals if debug logs are enabled.

func MountDebugLogEnabler

func MountDebugLogEnabler(prefix string, mux Muxer) func(http.Handler) http.Handler

MountDebugLogEnabler mounts an endpoint under the given prefix and returns a HTTP middleware that manages debug logs. The endpoint accepts a single query parameter "enable". If the parameter is set to "on" then debug logs are enabled for requests made to handlers returned by the middleware. If the parameter is set to "off" then debug logs are disabled.

func MountPprofHandlers

func MountPprofHandlers(mux Muxer)

MountPprofHandlers mounts pprof handlers under /debug/pprof/. The list of mounted handlers is:

/debug/pprof/
/debug/pprof/allocs
/debug/pprof/block
/debug/pprof/cmdline
/debug/pprof/goroutine
/debug/pprof/heap
/debug/pprof/mutex
/debug/pprof/profile
/debug/pprof/symbol
/debug/pprof/threadcreate
/debug/pprof/trace

See the pprof package documentation for more information.

Note: do not call this function on production servers accessible to the public! It exposes sensitive information about the server.

func StreamServerInterceptor

func StreamServerInterceptor() grpc.StreamServerInterceptor

StreamServerInterceptor returns a stream interceptor that manages whether debug log entries are written. Note: a change in the debug setting is effective only for the next stream request.

func UnaryServerInterceptor

func UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor return an interceptor that manages whether debug log entries are written.

Types

type FormatFunc

type FormatFunc func(context.Context, interface{}) string

FormatFunc is used to format the logged value for payloads and results.

type LogPayloadsOption

type LogPayloadsOption func(*options)

LogPayloadsOption is a function that applies a configuration option to the LogPayloads middleware.

func WithFormat

func WithFormat(fn FormatFunc) LogPayloadsOption

WithFormat sets the log format.

func WithMaxSize

func WithMaxSize(n int) LogPayloadsOption

WithMaxSize sets the maximum size of a single log message or value.

type Muxer

type Muxer interface {
	http.Handler
	Handle(pattern string, handler http.Handler)
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}

Muxer is the HTTP mux interface used by the debug package.

func Adapt

func Adapt(m goahttp.Muxer) Muxer

Adapt returns a debug.Muxer adapter for the given goahttp.Muxer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL