Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoteAddrKey ¶
func RemoteAddrKey() interface{}
RemoteAddr returns the contextual logging key for an HTTP request's remote address, as filled in by the enclosing http.Server.
func RequestInfo ¶
RequestInfo is a LoggerFunc that adds the request information described by logging keys in this package.
func RequestMethodKey ¶
func RequestMethodKey() interface{}
RequestMethodKey returns the contextual logging key for an HTTP request's method
func RequestURIKey ¶
func RequestURIKey() interface{}
RequestURIKey returns the contextual logging key for an HTTP request's unmodified URI
func SetLogger ¶
func SetLogger(base log.Logger, lf ...LoggerFunc) func(context.Context, *http.Request) context.Context
SetLogger produces a go-kit RequestFunc that inserts a go-kit Logger into the context. Zero or more LoggerFuncs can be provided to added key/values. Note that nothing is added to the base logger by default. If no LoggerFuncs are supplied, the base Logger is added to the context as is. In particular, RequestInfo must be used to inject the request method, uri, etc.
The base logger must be non-nil. There is no default applied.
The returned function can be used with xcontext.Populate.
Types ¶
type LoggerFunc ¶
LoggerFunc is a strategy for adding key/value pairs (possibly) based on an HTTP request. Functions of this type must append key/value pairs to the supplied slice and then return the new slice.
func Header ¶
func Header(headerName, keyName string) LoggerFunc
Header returns a logger func that extracts the value of a header and inserts it as the value of a logging key. If the header is not present in the request, a blank string is set as the logging key's value.
func PathVariable ¶
func PathVariable(variableName, keyName string) LoggerFunc
PathVariable returns a LoggerFunc that extracts the value of a gorilla/mux path variable and inserts it into the value of a logging key. If the variable is not present, a blank string is set as the logging key's value.