Documentation
¶
Index ¶
- Constants
- func FormatJSON(ctx context.Context, v interface{}) string
- func LogPayloads(opts ...LogPayloadsOption) func(goa.Endpoint) goa.Endpoint
- func MountDebugLogEnabler(prefix string, mux Muxer) func(http.Handler) http.Handler
- func MountPprofHandlers(mux Muxer)
- func StreamServerInterceptor() grpc.StreamServerInterceptor
- func UnaryServerInterceptor() grpc.UnaryServerInterceptor
- type FormatFunc
- type LogPayloadsOption
- type Muxer
Constants ¶
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 ¶
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 ¶
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 ¶
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 WithMaxSize ¶
func WithMaxSize(n int) LogPayloadsOption
WithMaxSize sets the maximum size of a single log message or value.