mirror of
https://github.com/restic/restic.git
synced 2025-01-03 13:45:20 +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:
parent
9ad8250a78
commit
07f4e7d10b
1 changed files with 6 additions and 1 deletions
|
@ -66,7 +66,12 @@ type loggingRoundTripper struct {
|
||||||
// RoundTripper returns a new http.RoundTripper which logs all requests (if
|
// RoundTripper returns a new http.RoundTripper which logs all requests (if
|
||||||
// debug is enabled). When debug is not enabled, upstream is returned.
|
// debug is enabled). When debug is not enabled, upstream is returned.
|
||||||
func RoundTripper(upstream http.RoundTripper) http.RoundTripper {
|
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) {
|
func (tr loggingRoundTripper) RoundTrip(req *http.Request) (res *http.Response, err error) {
|
||||||
|
|
Loading…
Reference in a new issue