xloghttp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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 NewErrorLog

func NewErrorLog(address string, logger log.Logger) *stdlibLog.Logger

func WithRequest

func WithRequest(original *http.Request, l log.Logger, b ...ParameterBuilder) *http.Request

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

func (Logging) Then

func (l Logging) Then(next http.Handler) http.Handler

func (Logging) ThenFunc

func (l Logging) ThenFunc(next http.HandlerFunc) http.Handler

type ParameterBuilder

type ParameterBuilder func(*http.Request, *Parameters)

ParameterBuilder appends logging key/value pairs to be used with a contextual request logger

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

func (*Parameters) Use

func (p *Parameters) Use(base log.Logger) log.Logger

Jump to

Keyboard shortcuts

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