Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

For debugging, provide a way to see data passing in and out of weaveproxy #1515

Closed
bboreham opened this issue Oct 8, 2015 · 2 comments
Closed
Assignees
Milestone

Comments

@bboreham
Copy link
Contributor

bboreham commented Oct 8, 2015

Sometimes, to understand what has gone wrong, we would like to see the exact json that went in and out of the proxy.

@tomwilkie
Copy link
Contributor

diff --git a/proxy/common.go b/proxy/common.go
index 4c0f3fc..8f457f2 100644
--- a/proxy/common.go
+++ b/proxy/common.go
@@ -42,6 +42,7 @@ func callWeave(args ...string) ([]byte, []byte, error) {

 func unmarshalRequestBody(r *http.Request, target interface{}) error {
        body, err := ioutil.ReadAll(r.Body)
+       Log.Infof("->requestBody: %s", body)
        if err != nil {
                return err
        }
@@ -60,6 +61,7 @@ func marshalRequestBody(r *http.Request, body interface{}) error {
        if err != nil {
                return err
        }
+       Log.Infof("<-requestBody: %s", newBody)
        r.Body = ioutil.NopCloser(bytes.NewReader(newBody))
        r.ContentLength = int64(len(newBody))
        return nil

Was helpful to me...

@bboreham bboreham self-assigned this Oct 13, 2015
@bboreham
Copy link
Contributor Author

Shall we just do this on --log-level=debug, or should I add an extra flag to turn it on?

rade added a commit that referenced this issue Oct 15, 2015
Print request and response json when debugging weaveproxy

Fixes #1515
@rade rade added this to the 1.2.0 milestone Oct 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants