logging

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 12 Imported by: 5 modules, 38 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(
	ctx context.Context,
	instrumentOpts instrument.Options,
	fields ...zapcore.Field,
) context.Context

NewContext returns a context has a zap logger with the extra fields added.

func NewContextWithGeneratedID

func NewContextWithGeneratedID(
	ctx context.Context,
	instrumentOpts instrument.Options,
) context.Context

NewContextWithGeneratedID returns a context with a generated id with a zap logger and an id field.

func NewContextWithID

func NewContextWithID(
	ctx context.Context,
	id string,
	instrumentOpts instrument.Options,
) context.Context

NewContextWithID returns a context which has a zap logger and an id field.

func ReadContextID

func ReadContextID(ctx context.Context) string

ReadContextID returns the context's id or "undefined".

func WithContext

func WithContext(ctx context.Context, instrumentOpts instrument.Options) *zap.Logger

WithContext returns a zap logger with as much context as possible.

func WithPanicErrorResponder added in v0.6.0

func WithPanicErrorResponder(
	next http.Handler,
	instrumentOpts instrument.Options,
) http.Handler

WithPanicErrorResponder wraps around the given handler, providing panic recovery and logging.

func WithResponseTimeAndPanicErrorLogging added in v0.6.0

func WithResponseTimeAndPanicErrorLogging(
	next http.Handler,
	instrumentOpts instrument.Options,
	opts ...MiddlewareOption,
) http.Handler

WithResponseTimeAndPanicErrorLogging wraps around the given handler, providing panic recovery and response time logging.

func WithResponseTimeAndPanicErrorLoggingFunc added in v0.6.0

func WithResponseTimeAndPanicErrorLoggingFunc(
	next func(w http.ResponseWriter, r *http.Request),
	instrumentOpts instrument.Options,
	opts ...MiddlewareOption,
) http.Handler

WithResponseTimeAndPanicErrorLoggingFunc wraps around the http request handler function, providing panic recovery and response time logging.

Types

type MiddlewareOption added in v1.0.1

type MiddlewareOption func(*middlewareOptions)

MiddlewareOption is an option to pass to a middleware.

func WithNoResponseLog added in v1.0.1

func WithNoResponseLog() MiddlewareOption

WithNoResponseLog is a middleware option to disable response logging.

func WithPostRequestMiddleware added in v1.0.1

func WithPostRequestMiddleware(m PostRequestMiddleware) MiddlewareOption

WithPostRequestMiddleware is a middleware option to set post-request middleware.

func WithPreRequestMiddleware added in v1.0.1

func WithPreRequestMiddleware(m PreRequestMiddleware) MiddlewareOption

WithPreRequestMiddleware is a middleware option to set pre-request middleware.

func WithResponseLogThreshold added in v1.0.1

func WithResponseLogThreshold(threshold time.Duration) MiddlewareOption

WithResponseLogThreshold is a middleware option to set response log threshold.

type PostRequestMiddleware added in v1.0.1

type PostRequestMiddleware func(req *http.Request, meta RequestMiddlewareMetadata)

PostRequestMiddleware is middleware that runs before a request.

type PreRequestMiddleware added in v1.0.1

type PreRequestMiddleware func(req *http.Request)

PreRequestMiddleware is middleware that runs before a request.

type RequestMiddlewareMetadata added in v1.0.1

type RequestMiddlewareMetadata struct {
	Start       time.Time
	End         time.Time
	Duration    time.Duration
	WroteHeader bool
	StatusCode  int
}

RequestMiddlewareMetadata is metadata available to middleware about a request.

Jump to

Keyboard shortcuts

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