req2log

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TypeValue = "request.2"
)

Variables

This section is empty.

Functions

func SetRequestParamPerms

func SetRequestParamPerms(perms RequestParamPerms)

func ToParams added in v1.13.0

func ToParams(r Request, idsExtractor extractor.IDsFromRequest, pathParamPerms, queryParamPerms, headerParamPerms ParamPerms) []wlog.Param

Types

type Logger

type Logger interface {
	Request(req Request)

	RequestParamPerms
}

Logger creates a request log entry based on the provided information.

func New

func New(w io.Writer, params ...LoggerCreatorParam) Logger

func NewFromCreator

func NewFromCreator(w io.Writer, creator wlog.LoggerCreator, params ...LoggerCreatorParam) Logger

type LoggerBuilder added in v1.13.0

type LoggerBuilder interface {
	LoggerCreator(creator wlog.LoggerCreator)
	IdsExtractor(idsExtractor extractor.IDsFromRequest)

	SafePathParams(safePathParams []string)
	ForbiddenPathParams(forbiddenPathParams []string)

	SafeQueryParams(safeQueryParams []string)
	ForbiddenQueryParams(forbiddenQueryParams []string)

	SafeHeaderParams(safeHeaderParams []string)
	ForbiddenHeaderParams(forbiddenHeaderParams []string)
}

type LoggerCreatorParam

type LoggerCreatorParam interface {
	Apply(builder LoggerBuilder)
}

func Creator

func Creator(creator wlog.LoggerCreator) LoggerCreatorParam

func Extractor

func Extractor(extractor extractor.IDsFromRequest) LoggerCreatorParam

func ForbiddenHeaderParams

func ForbiddenHeaderParams(forbiddenParams ...string) LoggerCreatorParam

func ForbiddenPathParams

func ForbiddenPathParams(forbiddenParams ...string) LoggerCreatorParam

func ForbiddenQueryParams

func ForbiddenQueryParams(forbiddenParams ...string) LoggerCreatorParam

func SafeHeaderParams

func SafeHeaderParams(safeParams ...string) LoggerCreatorParam

func SafePathParams

func SafePathParams(safeParams ...string) LoggerCreatorParam

func SafeQueryParams

func SafeQueryParams(safeParams ...string) LoggerCreatorParam

type ParamPerms

type ParamPerms interface {
	// Safe returns true if the parameter with the provided name is safe to log. Case-insensitive.
	Safe(paramName string) bool
	// Forbidden returns true if the provided parameter is forbidden from being logged (that is, it should not be logged
	// at all, even as an unsafe parameter). Case-insensitive.
	Forbidden(paramName string) bool
}

func CombinedParamPerms

func CombinedParamPerms(perms ...ParamPerms) ParamPerms

func NewParamPerms

func NewParamPerms(safe, forbidden []string) ParamPerms

type Request

type Request struct {
	// Request is the *http.Request associated with the event.
	Request *http.Request
	// RouteInfo contains the path template and path parameter values for the request.
	RouteInfo RouteInfo
	// ResponseStatus is the status code of the response to the request.
	ResponseStatus int
	// ResponseSize is the size of the response to the request.
	ResponseSize int64
	// Duration is the total time it took to process the request.
	Duration time.Duration
	// PathParamPerms determines the path parameters that are safe and forbidden for logging.
	PathParamPerms ParamPerms
	// QueryParamPerms determines the query parameters that are safe and forbidden for logging.
	QueryParamPerms ParamPerms
	// HeaderParamPerms determines the header parameters that are safe and forbidden for logging.
	HeaderParamPerms ParamPerms
}

Request represents an HTTP request that has been (or is about to be) completed. Contains information on the request such as the request itself, the status code of the response, etc.

type RequestParamPerms

type RequestParamPerms interface {
	PathParamPerms() ParamPerms
	QueryParamPerms() ParamPerms
	HeaderParamPerms() ParamPerms
}

func DefaultRequestParamPerms

func DefaultRequestParamPerms() RequestParamPerms

type RouteInfo

type RouteInfo struct {
	Template   string
	PathParams map[string]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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