Documentation ¶
Index ¶
- Constants
- func AddOriginFields(rw http.ResponseWriter, req *http.Request, next http.Handler, data *LogData)
- func AddServiceFields(rw http.ResponseWriter, req *http.Request, next http.Handler, data *LogData)
- func NewFieldHandler(next http.Handler, name string, value string, applyFn FieldApply) http.Handler
- func ParseAccessLog(data string) (map[string]string, error)
- func WrapHandler(handler *Handler) alice.Constructor
- type CommonLogFormatter
- type CoreLogData
- type FieldApply
- type FieldHandler
- type Handler
- type LogData
- type SaveRetries
Constants ¶
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" // RouterName is the map key used for the name of the Traefik router. RouterName = "RouterName" // ServiceName is the map key used for the name of the Traefik backend. ServiceName = "ServiceName" // ServiceURL is the map key used for the URL of the Traefik backend. ServiceURL = "ServiceURL" // ServiceAddr is the map key used for the IP:port of the Traefik backend (extracted from BackendURL) ServiceAddr = "ServiceAddr" // 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" // 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" // DownstreamStatus is the map key used for the HTTP status code returned to the client. DownstreamStatus = "DownstreamStatus" // 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" )
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 string = "common" // JSONFormat is the JSON logging format. JSONFormat string = "json" )
Variables ¶
This section is empty.
Functions ¶
func AddOriginFields ¶
AddOriginFields add origin fields
func AddServiceFields ¶
AddServiceFields add service fields
func NewFieldHandler ¶
NewFieldHandler creates a Field handler.
func ParseAccessLog ¶
ParseAccessLog parse line of access log and return a map with each fields
func WrapHandler ¶
func WrapHandler(handler *Handler) alice.Constructor
WrapHandler Wraps access log handler into an Alice Constructor.
Types ¶
type CommonLogFormatter ¶
type CommonLogFormatter struct{}
CommonLogFormatter provides formatting in the Traefik common log format.
type CoreLogData ¶
type CoreLogData map[string]interface{}
CoreLogData holds the fields computed from the request/response.
type FieldApply ¶
FieldApply function hook to add data in accesslog
type FieldHandler ¶
type FieldHandler struct {
// contains filtered or unexported fields
}
FieldHandler sends a new field to the logger.
func (*FieldHandler) ServeHTTP ¶
func (f *FieldHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler will write each request and its response to the access log.
func NewHandler ¶
NewHandler creates a new Handler.
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 GetLogData ¶
GetLogData gets the request context object that contains logging data. This creates data as the request passes through the middleware chain.
type SaveRetries ¶
type SaveRetries struct{}
SaveRetries is an implementation of RetryListener that stores RetryAttempts in the LogDataTable.