debuglog

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package debuglog provides a RoundTripper you can put into an HTTP client Transport to log requests made with that client. This has been proven useful for finding starr app API payloads, and as a general debug log wrapper for an integrating application.

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 {
	// Limit logged JSON payloads to this many bytes. 0=unlimited
	MaxBody int
	// This is where logs go. If not set they go to log.Printf.
	Debugf func(string, ...interface{})
	// This can be used for byte counters, but is optional otherwise.
	Caller Caller
	// Any strings in this list are replaced with <recated> in the log output.
	// Useful for hiding api keys and passwords from debug logs. String must be 4+ chars.
	Redact []string
}

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