Documentation ¶
Index ¶
- func NewConnStateLogger(logger log.Logger, key string, lvl level.Value) func(net.Conn, http.ConnState)
- func NewErrorLog(address string, logger log.Logger) *stdlibLog.Logger
- func WithRequest(original *http.Request, l log.Logger, b ...ParameterBuilder) *http.Request
- type Logging
- type ParameterBuilder
- type ParameterBuilders
- type Parameters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConnStateLogger ¶
func NewConnStateLogger(logger log.Logger, key string, lvl level.Value) func(net.Conn, http.ConnState)
NewConnStateLogger produces an http/Server.ConnState function that logs the connection state to the supplied logger.
func WithRequest ¶
WithRequest produces a new http.Request with a contextual logger bound to the context.
Types ¶
type Logging ¶
type Logging struct { Base log.Logger Builders ParameterBuilders }
Logging provides an Alice-style decorator that attaches a contextual logger to requests
type ParameterBuilder ¶
type ParameterBuilder func(*http.Request, *Parameters)
ParameterBuilder appends logging key/value pairs to be used with a contextual request logger
func Header ¶
func Header(name string) ParameterBuilder
Header returns a ParameterBuilder that appends the given HTTP header as a key/value pair
func Method ¶
func Method(key string) ParameterBuilder
Method returns a ParameterBuilder that adds the HTTP request method as a logging key/value pair
func Parameter ¶
func Parameter(name string) ParameterBuilder
Parameter returns a ParameterBuilder that appends the given HTTP query or form parameter as a key/value pair
func RemoteAddress ¶
func RemoteAddress(key string) ParameterBuilder
RemoteAddress is a ParameterBuilder that adds the HTTP remote address as a logging key/value pair
func URI ¶
func URI(key string) ParameterBuilder
URI returns a ParameterBuilder that adds the HTTP request URI as a logging key/value pair. Note that only the path is emitted as a logging value. The query string and any host:port information is omitted.
func Variable ¶
func Variable(name string) ParameterBuilder
Variable returns a ParameterBuilder that appends the given gorilla/mux path variable as a key/value pair
type ParameterBuilders ¶
type ParameterBuilders []ParameterBuilder
ParameterBuilders is a simple slice type for ParameterBuilder instances
func ProvideStandardBuilders ¶
func ProvideStandardBuilders() ParameterBuilders
ProvideStandardBuilders provides a standard set of logging fields for contextual handler logging. This function supplies the requestMethod, requestURI, and remoteAddr logging parameters.
type Parameters ¶
type Parameters struct {
// contains filtered or unexported fields
}
Parameters is a simple builder for logging key/value pairs
func (*Parameters) Add ¶
func (p *Parameters) Add(key, value interface{}) *Parameters