From 89905368b955edc763d7503cc63b6ca09389138a Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Sun, 26 Mar 2017 03:35:40 -0600 Subject: [PATCH] provider/openstack: Don't log the catalog (#13075) The OS_DEBUG feature has worked out great, but frequent logging of the service catalog during client initialization can make logging very chatty. This commit omits the service catalog in the logs. --- builtin/providers/openstack/types.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/builtin/providers/openstack/types.go b/builtin/providers/openstack/types.go index 7bcc755602c8..e2d19304c0d0 100644 --- a/builtin/providers/openstack/types.go +++ b/builtin/providers/openstack/types.go @@ -97,7 +97,9 @@ func (lrt *LogRoundTripper) logResponseBody(original io.ReadCloser, headers http return nil, err } debugInfo := lrt.formatJSON(bs.Bytes()) - log.Printf("[DEBUG] OpenStack Response Body: %s", debugInfo) + if debugInfo != "" { + log.Printf("[DEBUG] OpenStack Response Body: %s", debugInfo) + } return ioutil.NopCloser(strings.NewReader(bs.String())), nil } @@ -127,6 +129,13 @@ func (lrt *LogRoundTripper) formatJSON(raw []byte) string { } } + // Ignore the catalog + if v, ok := data["token"].(map[string]interface{}); ok { + if _, ok := v["catalog"]; ok { + return "" + } + } + pretty, err := json.MarshalIndent(data, "", " ") if err != nil { log.Printf("[DEBUG] Unable to re-marshal OpenStack JSON: %s", err)