Documentation
¶
Overview ¶
Package martianlog provides a Martian modifier that logs the request and response.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a modifier that logs requests and responses.
Example ¶
Output: -------------------------------------------------------------------------------- Request to http://example.com/path?querystring -------------------------------------------------------------------------------- GET http://example.com/path?querystring HTTP/1.1 Host: example.com Transfer-Encoding: chunked Content-Encoding: gzip request content -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- Response from http://example.com/path?querystring -------------------------------------------------------------------------------- HTTP/1.1 200 OK Content-Length: 16 Date: Tue, 15 Nov 1994 08:12:31 GMT Other-Header: values response content --------------------------------------------------------------------------------
func NewLogger ¶
func NewLogger() *Logger
NewLogger returns a logger that logs requests and responses, optionally logging the body. Log function defaults to martian.Infof.
func (*Logger) ModifyRequest ¶
ModifyRequest logs the request, optionally including the body.
The format logged is: -------------------------------------------------------------------------------- Request to http://www.google.com/path?querystring -------------------------------------------------------------------------------- GET /path?querystring HTTP/1.1 Host: www.google.com Connection: close Other-Header: values
request content --------------------------------------------------------------------------------
func (*Logger) ModifyResponse ¶
ModifyResponse logs the response, optionally including the body.
The format logged is: -------------------------------------------------------------------------------- Response from http://www.google.com/path?querystring -------------------------------------------------------------------------------- HTTP/1.1 200 OK Date: Tue, 15 Nov 1994 08:12:31 GMT Other-Header: values
response content --------------------------------------------------------------------------------
func (*Logger) SetHeadersOnly ¶
SetHeadersOnly sets whether to log the request/response body in the log.
func (*Logger) SetLogFunc ¶
SetLogFunc sets the logging function for the logger.