Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug log with concatenated string #128

Merged
merged 1 commit into from
Feb 23, 2018

Conversation

sudo-suhas
Copy link
Contributor

The debug logs become unreadable for concurrent requests made with resty. Here's some code which demonstrates the issue:

package main

import (
    "sync"
    "time"

    resty "gopkg.in/resty.v1"
)

func main() {
    client := resty.New().
        SetHostURL("https://jsonplaceholder.typicode.com").
        SetDebug(true).
        SetDebugBodyLimit(10000).
        SetTimeout(time.Minute).
        SetContentLength(true).
        SetHeaders(map[string]string{
            "Content-Type": "application/json; charset=utf-8",
            "Accept":       "application/json; charset=utf-8",
        })

    var wg sync.WaitGroup
    wg.Add(3)

    go func() {
        defer wg.Done()
        client.R().Get("/posts/1")
    }()

    go func() {
        defer wg.Done()
        client.R().Get("/posts/2")
    }()

    go func() {
        defer wg.Done()
        client.R().Get("/posts/3")
    }()

    wg.Wait()
}
debug logs (before)
λ go run concurrent_resty.go
RESTY 2018/02/19 17:00:43
---------------------- REQUEST LOG -----------------------
GET  /posts/3  HTTP/1.1


HOST   : jsonplaceholder.typicode.com
HEADERS:
                   Accept: application/json; charset=utf-8
             Content-Type: application/json; charset=utf-8
---------------------- REQUEST LOG -----------------------
GET  /posts/1  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
             Content-Type: application/json; charset=utf-8
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
                   Accept: application/json; charset=utf-8
BODY   :
***** NO CONTENT *****
---------------------- REQUEST LOG -----------------------
BODY   :
***** NO CONTENT *****
----------------------------------------------------------
----------------------------------------------------------
GET  /posts/2  HTTP/1.1
RESTY 2018/02/19 17:00:43 HOST   : jsonplaceholder.typicode.com
RESTY 2018/02/19 17:00:43 HEADERS:
RESTY 2018/02/19 17:00:43              Content-Type: application/json; charset=utf-8
RESTY 2018/02/19 17:00:43                    Accept: application/json; charset=utf-8
RESTY 2018/02/19 17:00:43                User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
RESTY 2018/02/19 17:00:43 BODY   :
***** NO CONTENT *****
RESTY 2018/02/19 17:00:43 ----------------------------------------------------------
RESTY 2018/02/19 17:00:43
---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-19T17:00:43.9766988+05:30
RESPONSE TIME   : 674.4783ms
HEADERS:
                           Via: 1.1 vegur
               Cf-Cache-Status: HIT
                        Cf-Ray: 3ef8e5506cc634dc-LHR
                    Set-Cookie: __cfduid=d0006d215aa47d5dac22b13dd966610751519039843; expires=Tue, 19-Feb-19 11:30:43 GMT; path=/; domain=.typicode.com; HttpOnly
                  X-Powered-By: Express
Access-Control-Allow-Credentials: true
                       Expires: Mon, 19 Feb 2018 15:30:43 GMT
        X-Content-Type-Options: nosniff
                  Content-Type: application/json; charset=utf-8
                          Vary: Origin, Accept-Encoding
                          Etag: W/"11b-USacuIw5a/iXAGdNKBvqr/TbMTc"
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                          Date: Mon, 19 Feb 2018 11:30:43 GMT
                 Cache-Control: public, max-age=14400
                        Pragma: no-cache
                        Server: cloudflare
BODY   :
{
   "userId": 1,
   "id": 3,
   "title": "ea molestias quasi exercitationem repellat qui ipsa sit aut",
   "body": "et iusto sed quo iure\nvoluptatem occaecati omnis eligendi aut ad\nvoluptatem doloribus vel accusantium quis pariatur\nmolestiae porro eius odio et labore et velit aut"
}
----------------------------------------------------------
RESTY 2018/02/19 17:00:43
---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-19T17:00:43.9807021+05:30
RESPONSE TIME   : 676.4792ms
HEADERS:
                          Date: Mon, 19 Feb 2018 11:30:43 GMT
                    Set-Cookie: __cfduid=d0006d215aa47d5dac22b13dd966610751519039843; expires=Tue, 19-Feb-19 11:30:43 GMT; path=/; domain=.typicode.com; HttpOnly
                          Vary: Origin, Accept-Encoding
                        Pragma: no-cache
                       Expires: Mon, 19 Feb 2018 15:30:43 GMT
        X-Content-Type-Options: nosniff
                           Via: 1.1 vegur
               Cf-Cache-Status: HIT
                 Cache-Control: public, max-age=14400
                          Etag: W/"116-jnDuMpjju89+9j7e0BqkdFsVRjs"
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                        Cf-Ray: 3ef8e5506cc434dc-LHR
                  Content-Type: application/json; charset=utf-8
                  X-Powered-By: Express
Access-Control-Allow-Credentials: true
                        Server: cloudflare
BODY   :
{
   "userId": 1,
   "id": 2,
   "title": "qui est esse",
   "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
}
----------------------------------------------------------
RESTY 2018/02/19 17:00:43
---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-19T17:00:43.989708+05:30
RESPONSE TIME   : 687.4875ms
HEADERS:
                    Set-Cookie: __cfduid=d0006d215aa47d5dac22b13dd966610751519039843; expires=Tue, 19-Feb-19 11:30:43 GMT; path=/; domain=.typicode.com; HttpOnly
                 Cache-Control: public, max-age=14400
                       Expires: Mon, 19 Feb 2018 15:30:43 GMT
        X-Content-Type-Options: nosniff
                           Via: 1.1 vegur
                        Cf-Ray: 3ef8e5507ce134dc-LHR
                          Date: Mon, 19 Feb 2018 11:30:43 GMT
                          Etag: W/"124-yiKdLzqO5gfBrJFrcdJ8Yq0LGnU"
                        Server: cloudflare
                  Content-Type: application/json; charset=utf-8
                          Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                  X-Powered-By: Express
                        Pragma: no-cache
               Cf-Cache-Status: HIT
BODY   :
{
   "userId": 1,
   "id": 1,
   "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
   "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
----------------------------------------------------------

This change builds up the log string by concatenation and prints it in a single function call.

debug logs (after)
RESTY 2018/02/19 17:13:49
---------------------- REQUEST LOG -----------------------
GET  /posts/3  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
             Content-Type: application/json; charset=utf-8
                   Accept: application/json; charset=utf-8
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
BODY   :
***** NO CONTENT *****
----------------------------------------------------------
RESTY 2018/02/19 17:13:49
---------------------- REQUEST LOG -----------------------
GET  /posts/1  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
             Content-Type: application/json; charset=utf-8
                   Accept: application/json; charset=utf-8
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
BODY   :
***** NO CONTENT *****
----------------------------------------------------------
RESTY 2018/02/19 17:13:49
---------------------- REQUEST LOG -----------------------
GET  /posts/2  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
                   Accept: application/json; charset=utf-8
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
             Content-Type: application/json; charset=utf-8
BODY   :
***** NO CONTENT *****
----------------------------------------------------------
RESTY 2018/02/19 17:13:50
---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-19T17:13:50.6824563+05:30
RESPONSE TIME   : 696.5046ms
HEADERS:
                  Content-Type: application/json; charset=utf-8
                          Vary: Origin, Accept-Encoding
                 Cache-Control: public, max-age=14400
                        Pragma: no-cache
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                        Server: cloudflare
                          Etag: W/"124-yiKdLzqO5gfBrJFrcdJ8Yq0LGnU"
                           Via: 1.1 vegur
                       Expires: Mon, 19 Feb 2018 15:43:50 GMT
        X-Content-Type-Options: nosniff
               Cf-Cache-Status: HIT
                        Cf-Ray: 3ef8f88548893488-LHR
                          Date: Mon, 19 Feb 2018 11:43:50 GMT
                    Set-Cookie: __cfduid=de8e7fb2dec26397f7a7a9b315e5b48ec1519040630; expires=Tue, 19-Feb-19 11:43:50 GMT; path=/; domain=.typicode.com; HttpOnly
                  X-Powered-By: Express
Access-Control-Allow-Credentials: true
BODY   :
{
   "userId": 1,
   "id": 1,
   "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
   "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
----------------------------------------------------------
RESTY 2018/02/19 17:13:50
---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-19T17:13:50.6834397+05:30
RESPONSE TIME   : 696.4949ms
HEADERS:
                        Pragma: no-cache
                       Expires: Mon, 19 Feb 2018 15:43:50 GMT
                          Etag: W/"116-jnDuMpjju89+9j7e0BqkdFsVRjs"
                        Cf-Ray: 3ef8f885588b3488-LHR
Access-Control-Allow-Credentials: true
                 Cache-Control: public, max-age=14400
                           Via: 1.1 vegur
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                  Content-Type: application/json; charset=utf-8
                    Set-Cookie: __cfduid=de8e7fb2dec26397f7a7a9b315e5b48ec1519040630; expires=Tue, 19-Feb-19 11:43:50 GMT; path=/; domain=.typicode.com; HttpOnly
                          Vary: Origin, Accept-Encoding
                        Server: cloudflare
                          Date: Mon, 19 Feb 2018 11:43:50 GMT
                  X-Powered-By: Express
        X-Content-Type-Options: nosniff
               Cf-Cache-Status: HIT
BODY   :
{
   "userId": 1,
   "id": 2,
   "title": "qui est esse",
   "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
}
----------------------------------------------------------
RESTY 2018/02/19 17:13:50
---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-19T17:13:50.6854416+05:30
RESPONSE TIME   : 700.4945ms
HEADERS:
                           Via: 1.1 vegur
                        Server: cloudflare
        X-Content-Type-Options: nosniff
               Cf-Cache-Status: HIT
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                    Set-Cookie: __cfduid=de8e7fb2dec26397f7a7a9b315e5b48ec1519040630; expires=Tue, 19-Feb-19 11:43:50 GMT; path=/; domain=.typicode.com; HttpOnly
                          Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
                        Pragma: no-cache
                       Expires: Mon, 19 Feb 2018 15:43:50 GMT
                        Cf-Ray: 3ef8f885588c3488-LHR
                          Date: Mon, 19 Feb 2018 11:43:50 GMT
                  Content-Type: application/json; charset=utf-8
                  X-Powered-By: Express
                 Cache-Control: public, max-age=14400
                          Etag: W/"11b-USacuIw5a/iXAGdNKBvqr/TbMTc"
BODY   :
{
   "userId": 1,
   "id": 3,
   "title": "ea molestias quasi exercitationem repellat qui ipsa sit aut",
   "body": "et iusto sed quo iure\nvoluptatem occaecati omnis eligendi aut ad\nvoluptatem doloribus vel accusantium quis pariatur\nmolestiae porro eius odio et labore et velit aut"
}
----------------------------------------------------------

@codecov
Copy link

codecov bot commented Feb 19, 2018

Codecov Report

Merging #128 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #128      +/-   ##
==========================================
- Coverage   96.33%   96.32%   -0.02%     
==========================================
  Files          10       10              
  Lines        1038     1034       -4     
==========================================
- Hits         1000      996       -4     
  Misses         21       21              
  Partials       17       17
Impacted Files Coverage Δ
middleware.go 92.09% <100%> (-0.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6cb0c07...d0b1ddb. Read the comment docs.

@jeevatkm
Copy link
Member

@sudo-suhas Thanks for the PR, I will have a look and get back.

Copy link
Member

@jeevatkm jeevatkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sudo-suhas please have a on comments and update it.

reqLog += fmt.Sprintf("BODY :\n%v\n", r.fmtBodyString()) +
"----------------------------------------------------------\n"

c.Log.Print(reqLog)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sudo-suhas Please update your code to

c.disableLogPrefix()
c.Log.Print(reqLog)
c.enableLogPrefix()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you tell me why you are requesting this change? The output seems correct with the current state from what I can tell. If I do the suggested change, because of concurrent execution, sometimes the prefix is present even though we disabled in the previous line:

debug logs
λ go run concurrent_resty.go

---------------------- REQUEST LOG -----------------------
GET  /posts/5  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
                   Accept: application/json; charset=utf-8
             Content-Type: application/json; charset=utf-8
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
BODY   :
***** NO CONTENT *****
----------------------------------------------------------
RESTY 2018/02/23 08:50:24
---------------------- REQUEST LOG -----------------------
GET  /posts/3  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
                   Accept: application/json; charset=utf-8
             Content-Type: application/json; charset=utf-8
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
BODY   :
***** NO CONTENT *****
----------------------------------------------------------
RESTY 2018/02/23 08:50:24
---------------------- REQUEST LOG -----------------------
GET  /posts/2  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
             Content-Type: application/json; charset=utf-8
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
                   Accept: application/json; charset=utf-8
BODY   :
***** NO CONTENT *****
----------------------------------------------------------
RESTY 2018/02/23 08:50:24
---------------------- REQUEST LOG -----------------------
GET  /posts/4  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
                   Accept: application/json; charset=utf-8
             Content-Type: application/json; charset=utf-8
BODY   :
***** NO CONTENT *****
----------------------------------------------------------

---------------------- REQUEST LOG -----------------------
GET  /posts/1  HTTP/1.1
HOST   : jsonplaceholder.typicode.com
HEADERS:
                   Accept: application/json; charset=utf-8
             Content-Type: application/json; charset=utf-8
               User-Agent: go-resty v1.2 - https://github.com/go-resty/resty
BODY   :
***** NO CONTENT *****
----------------------------------------------------------

---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-23T08:50:24.247412+05:30
RESPONSE TIME   : 216.1499ms
HEADERS:
                       Expires: Fri, 23 Feb 2018 07:20:23 GMT
                  Content-Type: application/json; charset=utf-8
                  X-Powered-By: Express
                        Pragma: no-cache
                           Via: 1.1 vegur
                        Server: cloudflare
                        Cf-Ray: 3f170c8dbdaf31c2-SIN
                    Set-Cookie: __cfduid=d8df9daebb9cc67d01d2dd80f101254771519356023; expires=Sat, 23-Feb-19 03:20:23 GMT; path=/; domain=.typicode.com; HttpOnly
Access-Control-Allow-Credentials: true
                 Cache-Control: public, max-age=14400
        X-Content-Type-Options: nosniff
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                          Date: Fri, 23 Feb 2018 03:20:23 GMT
                          Vary: Origin, Accept-Encoding
                          Etag: W/"124-yiKdLzqO5gfBrJFrcdJ8Yq0LGnU"
               Cf-Cache-Status: HIT
BODY   :
{
   "userId": 1,
   "id": 1,
   "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
   "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
----------------------------------------------------------
RESTY 2018/02/23 08:50:24
---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-23T08:50:24.247412+05:30
RESPONSE TIME   : 225.1572ms
HEADERS:
                          Date: Fri, 23 Feb 2018 03:20:23 GMT
               Cf-Cache-Status: HIT
                  X-Powered-By: Express
                 Cache-Control: public, max-age=14400
                        Pragma: no-cache
                          Etag: W/"11b-USacuIw5a/iXAGdNKBvqr/TbMTc"
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                    Set-Cookie: __cfduid=d8df9daebb9cc67d01d2dd80f101254771519356023; expires=Sat, 23-Feb-19 03:20:23 GMT; path=/; domain=.typicode.com; HttpOnly
                          Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
                           Via: 1.1 vegur
                        Server: cloudflare
                        Cf-Ray: 3f170c8dbdac31c2-SIN
                  Content-Type: application/json; charset=utf-8
                       Expires: Fri, 23 Feb 2018 07:20:23 GMT
        X-Content-Type-Options: nosniff
BODY   :
{
   "userId": 1,
   "id": 3,
   "title": "ea molestias quasi exercitationem repellat qui ipsa sit aut",
   "body": "et iusto sed quo iure\nvoluptatem occaecati omnis eligendi aut ad\nvoluptatem doloribus vel accusantium quis pariatur\nmolestiae porro eius odio et labore et velit aut"
}
----------------------------------------------------------

---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-23T08:50:24.247412+05:30
RESPONSE TIME   : 223.1548ms
HEADERS:
Access-Control-Allow-Credentials: true
                 Cache-Control: public, max-age=14400
                          Vary: Origin, Accept-Encoding
                  X-Powered-By: Express
                        Pragma: no-cache
                          Etag: W/"116-jnDuMpjju89+9j7e0BqkdFsVRjs"
               Cf-Cache-Status: HIT
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                    Set-Cookie: __cfduid=d8df9daebb9cc67d01d2dd80f101254771519356023; expires=Sat, 23-Feb-19 03:20:23 GMT; path=/; domain=.typicode.com; HttpOnly
                        Cf-Ray: 3f170c8dbdb331c2-SIN
                           Via: 1.1 vegur
                  Content-Type: application/json; charset=utf-8
                       Expires: Fri, 23 Feb 2018 07:20:23 GMT
        X-Content-Type-Options: nosniff
                        Server: cloudflare
                          Date: Fri, 23 Feb 2018 03:20:23 GMT
BODY   :
{
   "userId": 1,
   "id": 2,
   "title": "qui est esse",
   "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
}
----------------------------------------------------------

---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-23T08:50:24.7007314+05:30
RESPONSE TIME   : 671.4715ms
HEADERS:
                  X-Powered-By: Express
Access-Control-Allow-Credentials: true
                        Pragma: no-cache
                          Etag: W/"10e-HqG77o1RAmatkSwR36f4+Io6g1E"
                           Via: 1.1 vegur
               Cf-Cache-Status: REVALIDATED
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                        Server: cloudflare
                          Date: Fri, 23 Feb 2018 03:20:24 GMT
                 Cache-Control: public, max-age=14400
                       Expires: Fri, 23 Feb 2018 07:20:24 GMT
        X-Content-Type-Options: nosniff
                  Content-Type: application/json; charset=utf-8
                    Set-Cookie: __cfduid=d8df9daebb9cc67d01d2dd80f101254771519356023; expires=Sat, 23-Feb-19 03:20:23 GMT; path=/; domain=.typicode.com; HttpOnly
                          Vary: Origin, Accept-Encoding
                        Cf-Ray: 3f170c8dbdb131c2-SIN
BODY   :
{
   "userId": 1,
   "id": 4,
   "title": "eum et est occaecati",
   "body": "ullam et saepe reiciendis voluptatem adipisci\nsit amet autem assumenda provident rerum culpa\nquis hic commodi nesciunt rem tenetur doloremque ipsam iure\nquis sunt voluptatem rerum illo velit"
}
----------------------------------------------------------

---------------------- RESPONSE LOG -----------------------
STATUS          : 200 OK
RECEIVED AT     : 2018-02-23T08:50:24.8098105+05:30
RESPONSE TIME   : 790.564ms
HEADERS:
                          Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
                           Via: 1.1 vegur
                     Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                  Content-Type: application/json; charset=utf-8
                  X-Powered-By: Express
                        Pragma: no-cache
                        Cf-Ray: 3f170c8dbdad31c2-SIN
                          Date: Fri, 23 Feb 2018 03:20:24 GMT
                    Set-Cookie: __cfduid=d8df9daebb9cc67d01d2dd80f101254771519356023; expires=Sat, 23-Feb-19 03:20:23 GMT; path=/; domain=.typicode.com; HttpOnly
                 Cache-Control: public, max-age=14400
        X-Content-Type-Options: nosniff
                        Server: cloudflare
                       Expires: Fri, 23 Feb 2018 07:20:24 GMT
                          Etag: W/"e1-IivojO0CtPZmcMK0iydTbsfG7Wc"
               Cf-Cache-Status: REVALIDATED
BODY   :
{
   "userId": 1,
   "id": 5,
   "title": "nesciunt quas odio",
   "body": "repudiandae veniam quaerat sunt sed\nalias aut fugiat sit autem sed est\nvoluptatem omnis possimus esse voluptatibus quis\nest aut tenetur dolor neque"
}
----------------------------------------------------------

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sudo-suhas Okay, I see the prefix is printed in some of the log. Thanks for sharing sample log. This change is not needed. I will look into it later on.

c.enableLogPrefix()
resLog += "----------------------------------------------------------\n"

c.Log.Print(resLog)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sudo-suhas Please update your code to

c.disableLogPrefix()
c.Log.Print(resLog)
c.enableLogPrefix()

@jeevatkm jeevatkm added this to the v1.3 Milestone milestone Feb 23, 2018
@jeevatkm jeevatkm merged commit cf9fbbb into go-resty:master Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants