Exemple #1
0
// WriteOutgoingRequest is a helper method to write outgoing request events to a logger writer.
func WriteOutgoingRequest(writer logger.Logger, ts logger.TimeSource, req *HTTPRequestMeta) {
	buffer := writer.GetBuffer()
	defer writer.PutBuffer(buffer)
	buffer.WriteString(writer.Colorize(string(Event), logger.ColorGreen))
	buffer.WriteRune(logger.RuneSpace)
	buffer.WriteString(fmt.Sprintf("%s %s", req.Verb, req.URL.String()))
	writer.WriteWithTimeSource(ts, buffer.Bytes())
}
Exemple #2
0
// WriteOutgoingRequestResponse is a helper method to write outgoing request response events to a logger writer.
func WriteOutgoingRequestResponse(writer logger.Logger, ts logger.TimeSource, req *HTTPRequestMeta, res *HTTPResponseMeta, body []byte) {
	buffer := writer.GetBuffer()
	defer writer.PutBuffer(buffer)
	buffer.WriteString(writer.Colorize(string(EventResponse), logger.ColorGreen))
	buffer.WriteRune(logger.RuneSpace)
	buffer.WriteString(fmt.Sprintf("%s %s %s", writer.ColorizeByStatusCode(res.StatusCode, strconv.Itoa(res.StatusCode)), req.Verb, req.URL.String()))
	buffer.WriteRune(logger.RuneNewline)
	buffer.Write(body)
	writer.WriteWithTimeSource(ts, buffer.Bytes())
}