2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00

Only log HTTP requests when a debug log is configured

The logged HTTP requests are only visible when a debug log is
configured.
This commit is contained in:
Michael Eischer 2020-09-17 21:40:17 +02:00
parent 9ad8250a78
commit 07f4e7d10b

View File

@ -66,7 +66,12 @@ type loggingRoundTripper struct {
// RoundTripper returns a new http.RoundTripper which logs all requests (if
// debug is enabled). When debug is not enabled, upstream is returned.
func RoundTripper(upstream http.RoundTripper) http.RoundTripper {
return loggingRoundTripper{eofDetectRoundTripper{upstream}}
eofRoundTripper := eofDetectRoundTripper{upstream}
if opts.isEnabled {
// only use loggingRoundTripper if the debug log is configured
return loggingRoundTripper{eofRoundTripper}
}
return eofRoundTripper
}
func (tr loggingRoundTripper) RoundTrip(req *http.Request) (res *http.Response, err error) {