httplog

package
v0.26.5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 14 Imported by: 234

Documentation

Overview

Package httplog contains a helper object and functions to maintain a log along with an http response.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInfof added in v0.22.0

func AddInfof(ctx context.Context, format string, data ...interface{})

func AddKeyValue added in v0.23.0

func AddKeyValue(ctx context.Context, key string, value interface{})

AddKeyValue adds a (key, value) pair to the httplog associated with the request. Use this function if you want your data to show up in httplog in a more structured and readable way.

func DefaultStacktracePred

func DefaultStacktracePred(status int) bool

DefaultStacktracePred is the default implementation of StacktracePred.

func LogOf

func LogOf(req *http.Request, w http.ResponseWriter) logger

LogOf returns the logger hiding in w. If there is not an existing logger then a passthroughLogger will be created which will log to stdout immediately when Addf is called.

func SetStacktracePredicate added in v0.24.0

func SetStacktracePredicate(ctx context.Context, pred StacktracePred)

SetStacktracePredicate sets a custom stacktrace predicate for the logger associated with the given request context.

func Unlogged

Unlogged returns the original ResponseWriter, or w if it is not our inserted logger.

func WithLogging added in v0.16.4

func WithLogging(handler http.Handler, pred StacktracePred) http.Handler

WithLogging wraps the handler with logging.

Types

type ShouldLogRequestPred added in v0.23.0

type ShouldLogRequestPred func() bool

ShouldLogRequestPred returns true if logging should be enabled for this request

type StacktracePred

type StacktracePred func(httpStatus int) (logStacktrace bool)

StacktracePred returns true if a stacktrace should be logged for this status.

func StatusIsNot

func StatusIsNot(statuses ...int) StacktracePred

StatusIsNot returns a StacktracePred which will cause stacktraces to be logged for any status *not* in the given list.

Jump to

Keyboard shortcuts

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