accesslog

package
v1.7.40 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StartUTC is the map key used for the time at which request processing started.
	StartUTC = "StartUTC"
	// StartLocal is the map key used for the local time at which request processing started.
	StartLocal = "StartLocal"
	// Duration is the map key used for the total time taken by processing the response, including the origin server's time but
	// not the log writing time.
	Duration = "Duration"
	// FrontendName is the map key used for the name of the Traefik frontend.
	FrontendName = "FrontendName"
	// BackendName is the map key used for the name of the Traefik backend.
	BackendName = "BackendName"
	// BackendURL is the map key used for the URL of the Traefik backend.
	BackendURL = "BackendURL"
	// BackendAddr is the map key used for the IP:port of the Traefik backend (extracted from BackendURL)
	BackendAddr = "BackendAddr"
	// ClientAddr is the map key used for the remote address in its original form (usually IP:port).
	ClientAddr = "ClientAddr"
	// ClientHost is the map key used for the remote IP address from which the client request was received.
	ClientHost = "ClientHost"
	// ClientPort is the map key used for the remote TCP port from which the client request was received.
	ClientPort = "ClientPort"
	// ClientUsername is the map key used for the username provided in the URL, if present.
	ClientUsername = "ClientUsername"
	// RequestAddr is the map key used for the HTTP Host header (usually IP:port). This is treated as not a header by the Go API.
	RequestAddr = "RequestAddr"
	// RequestHost is the map key used for the HTTP Host server name (not including port).
	RequestHost = "RequestHost"
	// RequestPort is the map key used for the TCP port from the HTTP Host.
	RequestPort = "RequestPort"
	// RequestMethod is the map key used for the HTTP method.
	RequestMethod = "RequestMethod"
	// RequestPath is the map key used for the HTTP request URI, not including the scheme, host or port.
	RequestPath = "RequestPath"
	// RequestProtocol is the map key used for the version of HTTP requested.
	RequestProtocol = "RequestProtocol"
	// RequestLine is the original request line
	RequestLine = "RequestLine"
	// RequestContentSize is the map key used for the number of bytes in the request entity (a.k.a. body) sent by the client.
	RequestContentSize = "RequestContentSize"
	// RequestRefererHeader is the Referer header in the request
	RequestRefererHeader = "request_Referer"
	// RequestUserAgentHeader is the User-Agent header in the request
	RequestUserAgentHeader = "request_User-Agent"
	// OriginDuration is the map key used for the time taken by the origin server ('upstream') to return its response.
	OriginDuration = "OriginDuration"
	// OriginContentSize is the map key used for the content length specified by the origin server, or 0 if unspecified.
	OriginContentSize = "OriginContentSize"
	// OriginStatus is the map key used for the HTTP status code returned by the origin server.
	// If the request was handled by this Traefik instance (e.g. with a redirect), then this value will be absent.
	OriginStatus = "OriginStatus"
	// OriginStatusLine is the map key used for the HTTP status code and corresponding descriptive string.
	// If the request was handled by this Traefik instance (e.g. with a redirect), then this value will be absent.
	// Note that the actual message string might be different to what is reported here, depending on server behaviour.
	OriginStatusLine = "OriginStatusLine"
	// DownstreamStatus is the map key used for the HTTP status code returned to the client.
	DownstreamStatus = "DownstreamStatus"
	// DownstreamStatusLine is the map key used for the HTTP status line returned to the client.
	DownstreamStatusLine = "DownstreamStatusLine"
	// DownstreamContentSize is the map key used for the number of bytes in the response entity returned to the client.
	// This is in addition to the "Content-Length" header, which may be present in the origin response.
	DownstreamContentSize = "DownstreamContentSize"
	// RequestCount is the map key used for the number of requests received since the Traefik instance started.
	RequestCount = "RequestCount"
	// GzipRatio is the map key used for the response body compression ratio achieved.
	GzipRatio = "GzipRatio"
	// Overhead is the map key used for the processing time overhead caused by Traefik.
	Overhead = "Overhead"
	// RetryAttempts is the map key used for the amount of attempts the request was retried.
	RetryAttempts = "RetryAttempts"
)
View Source
const (
	// DataTableKey is the key within the request context used to
	// store the Log Data Table
	DataTableKey key = "LogDataTable"

	// CommonFormat is the common logging format (CLF)
	CommonFormat = "common"

	// JSONFormat is the JSON logging format
	JSONFormat = "json"
)

Variables

This section is empty.

Functions

func NewSaveBackend

func NewSaveBackend(next http.Handler, backendName string) http.Handler

NewSaveBackend creates a SaveBackend handler.

func NewSaveFrontend

func NewSaveFrontend(next http.Handler, frontendName string) http.Handler

NewSaveFrontend creates a SaveFrontend handler.

func NewSaveNegroniBackend added in v1.6.0

func NewSaveNegroniBackend(next negroni.Handler, backendName string) negroni.Handler

NewSaveNegroniBackend creates a SaveBackend handler.

func NewSaveNegroniFrontend

func NewSaveNegroniFrontend(next negroni.Handler, frontendName string) negroni.Handler

NewSaveNegroniFrontend creates a SaveNegroniFrontend handler.

func NewSaveNegroniUsername added in v1.7.4

func NewSaveNegroniUsername(next negroni.Handler) negroni.Handler

NewSaveNegroniUsername creates a SaveNegroniUsername handler.

func NewSaveUsername added in v1.7.4

func NewSaveUsername(next http.Handler) http.Handler

NewSaveUsername creates a SaveUsername handler.

func ParseAccessLog added in v1.6.0

func ParseAccessLog(data string) (map[string]string, error)

ParseAccessLog parse line of access log and return a map with each fields

func WithUserName added in v1.7.4

func WithUserName(req *http.Request, username string) *http.Request

WithUserName adds a username to a requests' context

Types

type CommonLogFormatter

type CommonLogFormatter struct{}

CommonLogFormatter provides formatting in the Traefik common log format

func (*CommonLogFormatter) Format

func (f *CommonLogFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format formats the log entry in the Traefik common log format

type CoreLogData

type CoreLogData map[string]interface{}

CoreLogData holds the fields computed from the request/response.

type LogData

type LogData struct {
	Core               CoreLogData
	Request            http.Header
	OriginResponse     http.Header
	DownstreamResponse http.Header
}

LogData is the data captured by the middleware so that it can be logged.

func GetLogDataTable

func GetLogDataTable(req *http.Request) *LogData

GetLogDataTable gets the request context object that contains logging data. This creates data as the request passes through the middleware chain.

type LogHandler

type LogHandler struct {
	// contains filtered or unexported fields
}

LogHandler will write each request and its response to the access log.

func NewLogHandler

func NewLogHandler(config *types.AccessLog) (*LogHandler, error)

NewLogHandler creates a new LogHandler

func (*LogHandler) Close

func (l *LogHandler) Close() error

Close closes the Logger (i.e. the file, drain logHandlerChan, etc).

func (*LogHandler) Rotate

func (l *LogHandler) Rotate() error

Rotate closes and reopens the log file to allow for rotation by an external source.

func (*LogHandler) ServeHTTP

func (l *LogHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc)

type SaveBackend

type SaveBackend struct {
	// contains filtered or unexported fields
}

SaveBackend sends the backend name to the logger. These are always used with a corresponding SaveFrontend handler.

func (*SaveBackend) ServeHTTP

func (sb *SaveBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type SaveFrontend

type SaveFrontend struct {
	// contains filtered or unexported fields
}

SaveFrontend sends the frontend name to the logger. These are sometimes used with a corresponding SaveBackend handler, but not always. For example, redirected requests don't reach a backend.

func (*SaveFrontend) ServeHTTP

func (sf *SaveFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type SaveNegroniBackend added in v1.6.0

type SaveNegroniBackend struct {
	// contains filtered or unexported fields
}

SaveNegroniBackend sends the backend name to the logger.

func (*SaveNegroniBackend) ServeHTTP added in v1.6.0

func (sb *SaveNegroniBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type SaveNegroniFrontend

type SaveNegroniFrontend struct {
	// contains filtered or unexported fields
}

SaveNegroniFrontend sends the frontend name to the logger.

func (*SaveNegroniFrontend) ServeHTTP

func (sf *SaveNegroniFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type SaveNegroniUsername added in v1.7.4

type SaveNegroniUsername struct {
	// contains filtered or unexported fields
}

SaveNegroniUsername adds the Username to the access logger data table.

func (*SaveNegroniUsername) ServeHTTP added in v1.7.4

func (sf *SaveNegroniUsername) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type SaveRetries

type SaveRetries struct{}

SaveRetries is an implementation of RetryListener that stores RetryAttempts in the LogDataTable.

func (*SaveRetries) Retried

func (s *SaveRetries) Retried(req *http.Request, attempt int)

Retried implements the RetryListener interface and will be called for each retry that happens.

type SaveUsername added in v1.7.4

type SaveUsername struct {
	// contains filtered or unexported fields
}

SaveUsername sends the Username name to the access logger.

func (*SaveUsername) ServeHTTP added in v1.7.4

func (sf *SaveUsername) ServeHTTP(rw http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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