debuglog

package
v0.0.0-...-f1df713 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package debuglog provides a RoundTripper you can put into an HTTP client Transport to log requests made with that client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller

type Caller func(status, method string, sentBytes, rcvdBytes int, err error)

Caller is a callback function you may use to collect statistics.

type Config

type Config struct {
	MaxBody int                          // Limit payloads to this many bytes. 0=unlimited
	Debugf  func(string, ...interface{}) // This is where logs go.
	Caller  Caller                       // This can be used for byte counters.
}

Config is the input data for the logger.

type LoggingRoundTripper

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

LoggingRoundTripper allows us to use a datacounter to log http request data.

func NewLoggingRoundTripper

func NewLoggingRoundTripper(config Config, next http.RoundTripper) *LoggingRoundTripper

NewLoggingRoundTripper returns a round tripper to log requests counts and response sizes.

func (*LoggingRoundTripper) RoundTrip

func (rt *LoggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies the http.RoundTripper interface.

Jump to

Keyboard shortcuts

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