Repository: go-resty/resty (go)

Issue:
Interface Panic
receiving a response (I don't know what exactly response from third party), and I've got a panic
So what should I need to avoid this panic. Thank you

Code
```
resty.
		SetDebug(false).
		SetTimeout(1*time.Minute).
		R().
		SetBody(param).
		SetHeader("authorization", <api token>).
		SetResult(&response).
		SetError(&responseErr).
		Post(v1_pathInternalAsaDiscountRefund)
```

Error
```
panic: interface conversion: interface {} is nil, not string
goroutine 2463 [running]:
github.com/go-resty/resty/v2.responseLogger(0xc0001ae960, 0xc00b441d10)
/go/pkg/mod/github.com/go-resty/resty/v2@v2.7.0/middleware.go:301 +0x75c
github.com/go-resty/resty/v2.(*Client).execute(0xc0001ae960, 0xc00b4511e0)
/go/pkg/mod/github.com/go-resty/resty/v2@v2.7.0/client.go:972 +0xbe4
github.com/go-resty/resty/v2. (*Request).Execute(0xc00b4511e0,
{0x1150590?, 0xc00b4d95a0?}, {0x117ec20, 0x21})
/go/pkg/mod/github.com/go-resty/resty/v2@v2.7.0/request.go:758 +0x5c5 github.com/go-resty/resty/v2. (*Request). Post(...)
/go/pkg/mod/github.com/go-resty/resty/v2@v2.7.0/request.go:699
```

Pull request:
For v2.8.0 release
Closes #651 

Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 52cbefb..6cbba59 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -20,14 +20,14 @@ jobs:
     name: Build
     strategy:
       matrix:
-        go: [ '1.20.x', '1.19.x' ]
+        go: [ '1.21.x']
         os: [ ubuntu-latest ]
 
     runs-on: ${{ matrix.os }}
 
     steps:
       - name: Checkout
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
         with:
           fetch-depth: 0
 
diff --git a/.github/workflows/label-actions.yml b/.github/workflows/label-actions.yml
index 8136c2c..264d861 100644
--- a/.github/workflows/label-actions.yml
+++ b/.github/workflows/label-actions.yml
@@ -6,18 +6,27 @@ on:
 
 jobs:
   build:
+    strategy:
+      matrix:
+        go: [ '1.21.x']
+        os: [ ubuntu-latest ]
+
     name: Run Build
     if: ${{ github.event.label.name == 'run-build' }}
-    runs-on: ubuntu-latest
+    runs-on: ${{ matrix.os }}
 
     steps:
       - name: Checkout
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
 
       - name: Setup Go
-        uses: actions/setup-go@v2
+        uses: actions/setup-go@v3
         with:
-          go-version: '1.18.x'
+          go-version: ${{ matrix.go }}
+          cache: true
+          cache-dependency-path: go.sum
 
       - name: Test
         run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic
diff --git a/README.md b/README.md
index 54b50e7..fce728d 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 <p align="center"><a href="#features">Features</a> section describes in detail about Resty capabilities</p>
 </p>
 <p align="center">
-<p align="center"><a href="https://github.com/go-resty/resty/actions/workflows/ci.yml?query=branch%3Amaster"><img src="https://github.com/go-resty/resty/actions/workflows/ci.yml/badge.svg" alt="Build Status"></a> <a href="https://codecov.io/gh/go-resty/resty/branch/master"><img src="https://codecov.io/gh/go-resty/resty/branch/master/graph/badge.svg" alt="Code Coverage"></a> <a href="https://goreportcard.com/report/go-resty/resty"><img src="https://goreportcard.com/badge/go-resty/resty" alt="Go Report Card"></a> <a href="https://github.com/go-resty/resty/releases/latest"><img src="https://img.shields.io/badge/version-2.7.0-blue.svg" alt="Release Version"></a> <a href="https://pkg.go.dev/github.com/go-resty/resty/v2"><img src="https://pkg.go.dev/badge/github.com/go-resty/resty" alt="GoDoc"></a> <a href="LICENSE"><img src="https://img.shields.io/github/license/go-resty/resty.svg" alt="License"></a> <a href="https://github.com/avelino/awesome-go"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Go"></a></p>
+<p align="center"><a href="https://github.com/go-resty/resty/actions/workflows/ci.yml?query=branch%3Amaster"><img src="https://github.com/go-resty/resty/actions/workflows/ci.yml/badge.svg" alt="Build Status"></a> <a href="https://codecov.io/gh/go-resty/resty/branch/master"><img src="https://codecov.io/gh/go-resty/resty/branch/master/graph/badge.svg" alt="Code Coverage"></a> <a href="https://goreportcard.com/report/go-resty/resty"><img src="https://goreportcard.com/badge/go-resty/resty" alt="Go Report Card"></a> <a href="https://github.com/go-resty/resty/releases/latest"><img src="https://img.shields.io/badge/version-2.8.0-blue.svg" alt="Release Version"></a> <a href="https://pkg.go.dev/github.com/go-resty/resty/v2"><img src="https://pkg.go.dev/badge/github.com/go-resty/resty" alt="GoDoc"></a> <a href="LICENSE"><img src="https://img.shields.io/github/license/go-resty/resty.svg" alt="License"></a> <a href="https://github.com/avelino/awesome-go"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Go"></a></p>
 </p>
 <p align="center">
 <h4 align="center">Resty Communication Channels</h4>
@@ -13,7 +13,7 @@
 
 ## News
 
-  * v2.7.0 [released](https://github.com/go-resty/resty/releases/tag/v2.7.0) and tagged on Nov 03, 2021.
+  * v2.8.0 [released](https://github.com/go-resty/resty/releases/tag/v2.8.0) and tagged on Sep 17, 2023.
   * v2.0.0 [released](https://github.com/go-resty/resty/releases/tag/v2.0.0) and tagged on Jul 16, 2019.
   * v1.12.0 [released](https://github.com/go-resty/resty/releases/tag/v1.12.0) and tagged on Feb 27, 2019.
   * v1.0 released and tagged on Sep 25, 2017. - Resty's first version was released on Sep 15, 2015 then it grew gradually as a very handy and helpful library. Its been a two years since first release. I'm very thankful to Resty users and its [contributors](https://github.com/go-resty/resty/graphs/contributors).
@@ -477,7 +477,7 @@ resp, err := client.R().
 client := resty.New()
 
 // Setting output directory path, If directory not exists then resty creates one!
-// This is optional one, if you're planning using absoule path in
+// This is optional one, if you're planning using absolute path in
 // `Request.SetOutput` and can used together.
 client.SetOutputDirectory("/Users/jeeva/Downloads")
 
@@ -822,7 +822,7 @@ client.SetCookies(cookies)
 client.SetQueryParam("user_id", "00001")
 client.SetQueryParams(map[string]string{ // sample of those who use this manner
       "api_key": "api-key-here",
-      "api_secert": "api-secert",
+      "api_secret": "api-secret",
     })
 client.R().SetQueryString("productId=232&template=fresh-sample&cat=resty&source=google&kw=buy a lot more")
 
diff --git a/client.go b/client.go
index d72c5ce..b6c4a2e 100644
--- a/client.go
+++ b/client.go
@@ -327,7 +327,7 @@ func (c *Client) SetQueryParams(params map[string]string) *Client {
 }
 
 // SetFormData method sets Form parameters and their values in the client instance.
-// It's applicable only HTTP method `POST` and `PUT` and requets content type would be set as
+// It's applicable only HTTP method `POST` and `PUT` and request content type would be set as
 // `application/x-www-form-urlencoded`. These form data will be added to all the request raised from
 // this client instance. Also it can be overridden at request level form data.
 //
@@ -352,7 +352,7 @@ func (c *Client) SetFormData(data map[string]string) *Client {
 //
 //	client.SetBasicAuth("go-resty", "welcome")
 //
-// This basic auth information gets added to all the request rasied from this client instance.
+// This basic auth information gets added to all the request raised from this client instance.
 // Also it can be overridden or set one at the request level is supported.
 //
 // See `Request.SetBasicAuth`.
@@ -370,7 +370,7 @@ func (c *Client) SetBasicAuth(username, password string) *Client {
 //
 //	client.SetAuthToken("BC594900518B4F7EAC75BD37F019E08FBC594900518B4F7EAC75BD37F019E08F")
 //
-// This auth token gets added to all the requests rasied from this client instance.
+// This auth token gets added to all the requests raised from this client instance.
 // Also it can be overridden or set one at the request level is supported.
 //
 // See `Request.SetAuthToken`.
@@ -387,7 +387,7 @@ func (c *Client) SetAuthToken(token string) *Client {
 //
 //	client.SetAuthScheme("OAuth")
 //
-// This auth scheme gets added to all the requests rasied from this client instance.
+// This auth scheme gets added to all the requests raised from this client instance.
 // Also it can be overridden or set one at the request level is supported.
 //
 // Information about auth schemes can be found in RFC7235 which is linked to below
@@ -476,7 +476,7 @@ func (c *Client) OnBeforeRequest(m RequestMiddleware) *Client {
 
 // OnAfterResponse method appends response middleware into the after response chain.
 // Once we receive response from host server, default Resty response middleware
-// gets applied and then user assigened response middlewares applied.
+// gets applied and then user assigned response middlewares applied.
 //
 //	client.OnAfterResponse(func(c *resty.Client, r *resty.Response) error {
 //			// Now you have access to Client and Response instance
@@ -506,7 +506,7 @@ func (c *Client) OnAfterResponse(m ResponseMiddleware) *Client {
 //	})
 //
 // Out of the OnSuccess, OnError, OnInvalid, OnPanic callbacks, exactly one
-// set will be invoked for each call to Request.Execute() that comletes.
+// set will be invoked for each call to Request.Execute() that completes.
 func (c *Client) OnError(h ErrorHook) *Client {
 	c.errorHooks = append(c.errorHooks, h)
 	return c
@@ -516,29 +516,35 @@ func (c *Client) OnError(h ErrorHook) *Client {
 // succeeds.  This is called after all retries have been attempted (if any).
 //
 // Out of the OnSuccess, OnError, OnInvalid, OnPanic callbacks, exactly one
-// set will be invoked for each call to Request.Execute() that comletes.
+// set will be invoked for each call to Request.Execute() that completes.
+//
+// Since v2.8.0
 func (c *Client) OnSuccess(h SuccessHook) *Client {
 	c.successHooks = append(c.successHooks, h)
 	return c
 }
 
-// OnInvalid method adds a callback that will be run whever a request execution
+// OnInvalid method adds a callback that will be run whenever a request execution
 // fails before it starts because the request is invalid.
 //
 // Out of the OnSuccess, OnError, OnInvalid, OnPanic callbacks, exactly one
-// set will be invoked for each call to Request.Execute() that comletes.
+// set will be invoked for each call to Request.Execute() that completes.
+//
+// Since v2.8.0
 func (c *Client) OnInvalid(h ErrorHook) *Client {
 	c.invalidHooks = append(c.invalidHooks, h)
 	return c
 }
 
-// OnPanic method adds a callback that will be run whever a request execution
+// OnPanic method adds a callback that will be run whenever a request execution
 // panics.
 //
 // Out of the OnSuccess, OnError, OnInvalid, OnPanic callbacks, exactly one
 // set will be invoked for each call to Request.Execute() that completes.
 // If an OnSuccess, OnError, or OnInvalid callback panics, then the exactly
 // one rule can be violated.
+//
+// Since v2.8.0
 func (c *Client) OnPanic(h ErrorHook) *Client {
 	c.panicHooks = append(c.panicHooks, h)
 	return c
@@ -547,7 +553,7 @@ func (c *Client) OnPanic(h ErrorHook) *Client {
 // SetPreRequestHook method sets the given pre-request function into resty client.
 // It is called right before the request is fired.
 //
-// Note: Only one pre-request hook can be registered. Use `client.OnBeforeRequest` for mutilple.
+// Note: Only one pre-request hook can be registered. Use `client.OnBeforeRequest` for multiple.
 func (c *Client) SetPreRequestHook(h PreRequestHook) *Client {
 	if c.preReqHook != nil {
 		c.log.Warnf("Overwriting an existing pre-request hook: %s", functionName(h))
@@ -561,6 +567,8 @@ func (c *Client) SetPreRequestHook(h PreRequestHook) *Client {
 // For `Response` it logs information such as Status, Response Time, Headers, Body if it has one.
 //
 //	client.SetDebug(true)
+//
+// Also it can be enabled at request level for particular request, see `Request.SetDebug`.
 func (c *Client) SetDebug(d bool) *Client {
 	c.Debug = d
 	return c
@@ -655,7 +663,7 @@ func (c *Client) SetError(err interface{}) *Client {
 	return c
 }
 
-// SetRedirectPolicy method sets the client redirect poilicy. Resty provides ready to use
+// SetRedirectPolicy method sets the client redirect policy. Resty provides ready to use
 // redirect policies. Wanna create one for yourself refer to `redirect.go`.
 //
 //	client.SetRedirectPolicy(FlexibleRedirectPolicy(20))
@@ -716,6 +724,8 @@ func (c *Client) SetRetryAfter(callback RetryAfterFunc) *Client {
 
 // SetJSONMarshaler method sets the JSON marshaler function to marshal the request body.
 // By default, Resty uses `encoding/json` package to marshal the request body.
+//
+// Since v2.8.0
 func (c *Client) SetJSONMarshaler(marshaler func(v interface{}) ([]byte, error)) *Client {
 	c.JSONMarshal = marshaler
 	return c
@@ -723,6 +733,8 @@ func (c *Client) SetJSONMarshaler(marshaler func(v interface{}) ([]byte, error))
 
 // SetJSONUnmarshaler method sets the JSON unmarshaler function to unmarshal the response body.
 // By default, Resty uses `encoding/json` package to unmarshal the response body.
+//
+// Since v2.8.0
 func (c *Client) SetJSONUnmarshaler(unmarshaler func(data []byte, v interface{}) error) *Client {
 	c.JSONUnmarshal = unmarshaler
 	return c
@@ -730,6 +742,8 @@ func (c *Client) SetJSONUnmarshaler(unmarshaler func(data []byte, v interface{})
 
 // SetXMLMarshaler method sets the XML marshaler function to marshal the request body.
 // By default, Resty uses `encoding/xml` package to marshal the request body.
+//
+// Since v2.8.0
 func (c *Client) SetXMLMarshaler(marshaler func(v interface{}) ([]byte, error)) *Client {
 	c.XMLMarshal = marshaler
 	return c
@@ -737,6 +751,8 @@ func (c *Client) SetXMLMarshaler(marshaler func(v interface{}) ([]byte, error))
 
 // SetXMLUnmarshaler method sets the XML unmarshaler function to unmarshal the response body.
 // By default, Resty uses `encoding/xml` package to unmarshal the response body.
+//
+// Since v2.8.0
 func (c *Client) SetXMLUnmarshaler(unmarshaler func(data []byte, v interface{}) error) *Client {
 	c.XMLUnmarshal = unmarshaler
 	return c
@@ -914,7 +930,7 @@ func (c *Client) SetOutputDirectory(dirPath string) *Client {
 // - It overwrites the Resty client transport instance and it's configurations.
 //
 //	transport := &http.Transport{
-//		// somthing like Proxying to httptest.Server, etc...
+//		// something like Proxying to httptest.Server, etc...
 //		Proxy: func(req *http.Request) (*url.URL, error) {
 //			return url.Parse(server.URL)
 //		},
@@ -1020,6 +1036,8 @@ func (c *Client) SetPathParams(params map[string]string) *Client {
 //
 // Also it can be overridden at request level Path Params options,
 // see `Request.SetPathParam` or `Request.SetPathParams`.
+//
+// Since v2.8.0
 func (c *Client) SetRawPathParam(param, value string) *Client {
 	c.RawPathParams[param] = value
 	return c
@@ -1043,6 +1061,8 @@ func (c *Client) SetRawPathParam(param, value string) *Client {
 //
 // Also it can be overridden at request level Path Params options,
 // see `Request.SetPathParam` or `Request.SetPathParams`.
+//
+// Since v2.8.0
 func (c *Client) SetRawPathParams(params map[string]string) *Client {
 	for p, v := range params {
 		c.SetRawPathParam(p, v)
@@ -1207,6 +1227,8 @@ func (c *Client) tlsConfig() (*tls.Config, error) {
 
 // Transport method returns `*http.Transport` currently in use or error
 // in case currently used `transport` is not a `*http.Transport`.
+//
+// Since v2.8.0 become exported method.
 func (c *Client) Transport() (*http.Transport, error) {
 	if transport, ok := c.httpClient.Transport.(*http.Transport); ok {
 		return transport, nil
diff --git a/middleware.go b/middleware.go
index 9b7b33d..6f866be 100644
--- a/middleware.go
+++ b/middleware.go
@@ -273,7 +273,7 @@ func addCredentials(c *Client, r *Request) error {
 }
 
 func requestLogger(c *Client, r *Request) error {
-	if c.Debug {
+	if c.Debug || r.Debug {
 		rr := r.RawRequest
 		rl := &RequestLog{Header: copyHeaders(rr.Header), Body: r.fmtBodyString(c.debugBodySizeLimit)}
 		if c.requestLog != nil {
@@ -303,7 +303,7 @@ func requestLogger(c *Client, r *Request) error {
 //_______________________________________________________________________
 
 func responseLogger(c *Client, res *Response) error {
-	if c.Debug {
+	if c.Debug || res.Request.Debug {
 		rl := &ResponseLog{Header: copyHeaders(res.Header()), Body: res.fmtBodyString(c.debugBodySizeLimit)}
 		if c.responseLog != nil {
 			if err := c.responseLog(rl); err != nil {
diff --git a/redirect.go b/redirect.go
index fdca9fe..ed58d73 100644
--- a/redirect.go
+++ b/redirect.go
@@ -13,6 +13,7 @@ import (
 )
 
 var (
+	// Since v2.8.0
 	ErrAutoRedirectDisabled = errors.New("auto redirect is disabled")
 )
 
@@ -20,7 +21,7 @@ type (
 	// RedirectPolicy to regulate the redirects in the resty client.
 	// Objects implementing the RedirectPolicy interface can be registered as
 	//
-	// Apply function should return nil to continue the redirect jounery, otherwise
+	// Apply function should return nil to continue the redirect journey, otherwise
 	// return error to stop the redirect.
 	RedirectPolicy interface {
 		Apply(req *http.Request, via []*http.Request) error
@@ -92,7 +93,7 @@ func getHostname(host string) (hostname string) {
 }
 
 // By default Golang will not redirect request headers
-// after go throughing various discussion comments from thread
+// after go throwing various discussion comments from thread
 // https://github.com/golang/go/issues/4800
 // Resty will add all the headers during a redirect for the same host
 func checkHostAndAddHeaders(cur *http.Request, pre *http.Request) {
diff --git a/request.go b/request.go
index fed6d4f..fec0976 100644
--- a/request.go
+++ b/request.go
@@ -44,6 +44,7 @@ type Request struct {
 	SRV           *SRVRecord
 	UserInfo      *User
 	Cookies       []*http.Cookie
+	Debug         bool
 
 	// Attempt is to represent the request attempt made during a Resty
 	// request execution flow, including retry count.
@@ -488,7 +489,7 @@ func (r *Request) SetAuthToken(token string) *Request {
 //
 //	client.R().SetAuthScheme("OAuth")
 //
-// This auth header scheme gets added to all the request rasied from this client instance.
+// This auth header scheme gets added to all the request raised from this client instance.
 // Also it can be overridden or set one at the request level is supported.
 //
 // Information about Auth schemes can be found in RFC7235 which is linked to below along with the page containing
@@ -640,6 +641,8 @@ func (r *Request) SetPathParams(params map[string]string) *Request {
 //
 // Also you can override Path Params value, which was set at client instance
 // level.
+//
+// Since v2.8.0
 func (r *Request) SetRawPathParam(param, value string) *Request {
 	r.RawPathParams[param] = value
 	return r
@@ -663,6 +666,8 @@ func (r *Request) SetRawPathParam(param, value string) *Request {
 //
 // Also you can override Path Params value, which was set at client instance
 // level.
+//
+// Since v2.8.0
 func (r *Request) SetRawPathParams(params map[string]string) *Request {
 	for p, v := range params {
 		r.SetRawPathParam(p, v)
@@ -741,6 +746,17 @@ func (r *Request) SetLogger(l Logger) *Request {
 	return r
 }
 
+// SetDebug method enables the debug mode on current request Resty request, It logs
+// the details current request and response.
+// For `Request` it logs information such as HTTP verb, Relative URL path, Host, Headers, Body if it has one.
+// For `Response` it logs information such as Status, Response Time, Headers, Body if it has one.
+//
+//	client.R().SetDebug(true)
+func (r *Request) SetDebug(d bool) *Request {
+	r.Debug = d
+	return r
+}
+
 // AddRetryCondition method adds a retry condition function to the request's
 // array of functions that are checked to determine if the request is retried.
 // The request will retry if any of the functions return true and error is nil.
diff --git a/resty.go b/resty.go
index 930a909..5bbb842 100644
--- a/resty.go
+++ b/resty.go
@@ -14,7 +14,7 @@ import (
 )
 
 // Version # of resty
-const Version = "2.7.0"
+const Version = "2.8.0"
 
 // New method creates a new Resty client.
 func New() *Client {


Test patch:
diff --git a/client_test.go b/client_test.go
index 966e029..da098fb 100644
--- a/client_test.go
+++ b/client_test.go
@@ -711,12 +711,12 @@ func TestLogCallbacks(t *testing.T) {
 	c.outputLogTo(&lgr)
 
 	c.OnRequestLog(func(r *RequestLog) error {
-		// masking authorzation header
+		// masking authorization header
 		r.Header.Set("Authorization", "Bearer *******************************")
 		return nil
 	})
 	c.OnResponseLog(func(r *ResponseLog) error {
-		r.Header.Add("X-Debug-Resposne-Log", "Modified :)")
+		r.Header.Add("X-Debug-Response-Log", "Modified :)")
 		r.Body += "\nModified the response body content"
 		return nil
 	})
@@ -734,7 +734,7 @@ func TestLogCallbacks(t *testing.T) {
 	// Validating debug log updates
 	logInfo := lgr.String()
 	assertEqual(t, true, strings.Contains(logInfo, "Bearer *******************************"))
-	assertEqual(t, true, strings.Contains(logInfo, "X-Debug-Resposne-Log"))
+	assertEqual(t, true, strings.Contains(logInfo, "X-Debug-Response-Log"))
 	assertEqual(t, true, strings.Contains(logInfo, "Modified the response body content"))
 
 	// Error scenario
diff --git a/request_test.go b/request_test.go
index 2c06cae..a385097 100644
--- a/request_test.go
+++ b/request_test.go
@@ -711,11 +711,11 @@ func TestFormDataDisableWarn(t *testing.T) {
 	c := dc()
 	c.SetFormData(map[string]string{"zip_code": "00000", "city": "Los Angeles"}).
 		SetContentLength(true).
-		SetDebug(true).
 		SetDisableWarn(true)
 	c.outputLogTo(io.Discard)
 
 	resp, err := c.R().
+		SetDebug(true).
 		SetFormData(map[string]string{"first_name": "Jeevanandam", "last_name": "M", "zip_code": "00001"}).
 		SetBasicAuth("myuser", "mypass").
 		Post(ts.URL + "/profile")
@@ -1317,7 +1317,7 @@ func TestDetectContentTypeForPointer(t *testing.T) {
 }
 
 type ExampleUser struct {
-	FirstName string `json:"frist_name"`
+	FirstName string `json:"first_name"`
 	LastName  string `json:"last_name"`
 	ZipCode   string `json:"zip_code"`
 }
@@ -1748,7 +1748,7 @@ func TestPathParamURLInput(t *testing.T) {
 	ts := createGetServer(t)
 	defer ts.Close()
 
-	c := dc().SetDebug(true).
+	c := dc().
 		SetBaseURL(ts.URL).
 		SetPathParams(map[string]string{
 			"userId": "sample@sample.com",
@@ -1756,6 +1756,7 @@ func TestPathParamURLInput(t *testing.T) {
 		})
 
 	resp, err := c.R().
+		SetDebug(true).
 		SetPathParams(map[string]string{
 			"subAccountId": "100002",
 			"website":      "https://example.com",
@@ -1900,7 +1901,8 @@ func TestDebugLoggerRequestBodyTooLarge(t *testing.T) {
 
 	// upload a text file with no more than 512 bytes
 	output = bytes.NewBufferString("")
-	resp, err = New().SetDebug(true).outputLogTo(output).SetDebugBodyLimit(debugBodySizeLimit).R().
+	resp, err = New().outputLogTo(output).SetDebugBodyLimit(debugBodySizeLimit).R().
+		SetDebug(true).
 		SetFile("file", filepath.Join(getTestDataPath(), "text-file.txt")).
 		SetHeader("Content-Type", "text/plain").
 		Post(ts.URL + "/upload")
@@ -1927,7 +1929,8 @@ func TestDebugLoggerRequestBodyTooLarge(t *testing.T) {
 
 	// post form with no more than 512 bytes data
 	output = bytes.NewBufferString("")
-	resp, err = New().SetDebug(true).outputLogTo(output).SetDebugBodyLimit(debugBodySizeLimit).R().
+	resp, err = New().outputLogTo(output).SetDebugBodyLimit(debugBodySizeLimit).R().
+		SetDebug(true).
 		SetFormData(map[string]string{
 			"first_name": "Alex",
 			"last_name":  "C",
@@ -1954,7 +1957,8 @@ func TestDebugLoggerRequestBodyTooLarge(t *testing.T) {
 
 	// post slice with more than 512 bytes data
 	output = bytes.NewBufferString("")
-	resp, err = New().SetDebug(true).outputLogTo(output).SetDebugBodyLimit(debugBodySizeLimit).R().
+	resp, err = New().outputLogTo(output).SetDebugBodyLimit(debugBodySizeLimit).R().
+		SetDebug(true).
 		SetBody([]string{strings.Repeat("C", int(debugBodySizeLimit))}).
 		SetBasicAuth("myuser", "mypass").
 		Post(formTs.URL + "/profile")