From aaf65a47a7a6d9e45b77815ea252a302eefe1096 Mon Sep 17 00:00:00 2001 From: Zhang Wei Date: Thu, 17 Dec 2015 15:55:39 +0800 Subject: [PATCH] Better debug message for post form data Print json format instead of default `%q` Signed-off-by: Zhang Wei --- api/server/middleware.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/server/middleware.go b/api/server/middleware.go index 548d0c2911..91f72f1157 100644 --- a/api/server/middleware.go +++ b/api/server/middleware.go @@ -38,7 +38,12 @@ func debugRequestMiddleware(handler httputils.APIFunc) httputils.APIFunc { if _, exists := postForm["password"]; exists { postForm["password"] = "*****" } - logrus.Debugf("form data: %q", postForm) + formStr, errMarshal := json.Marshal(postForm) + if errMarshal == nil { + logrus.Debugf("form data: %s", string(formStr)) + } else { + logrus.Debugf("form data: %q", postForm) + } } } }