Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultLogRequest = func(req *http.Request) { ctx := req.Context() fields := []zap.Field{ zap.String("host", req.Host), zap.String("method", req.Method), zap.String("url", req.URL.String()), } if reqID := log.GetReqID(ctx); len(reqID) > 0 { fields = append(fields, zap.String("req_id", reqID)) } l := log.Logger if l.Core().Enabled(zap.DebugLevel) { fields = append(fields, log.DecodeBodyFromRequest(req)) fields = append(fields, log.DecodeHeaderFromRequest(req)) } l.Info("Outgoing HTTP Request", fields...) }
Used if transport.LogRequest is not set.
View Source
var DefaultLogResponse = func(resp *http.Response) { ctx := resp.Request.Context() l := log.Logger fields := []zap.Field{ zap.Int("status", resp.StatusCode), zap.String("uri", resp.Request.URL.String()), zap.String("host", resp.Request.Host), } if reqID := log.GetReqID(ctx); len(reqID) > 0 { fields = append(fields, zap.String("req_id", reqID)) } if l.Core().Enabled(zap.DebugLevel) { fields = append(fields, log.DecodeBodyFromResponse(resp)) fields = append(fields, log.DecodeHeaderFromResponse(resp)) } l.Info("Incoming HTTP Response", fields...) }
Used if transport.LogResponse is not set.
View Source
var LoggingTransport = &Transport{ Transport: http.DefaultTransport, }
THe default logging transport that wraps http.DefaultTransport.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.