Skip to content

Commit

Permalink
provider/openstack: Don't log the catalog (#13075)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jtopjian authored and stack72 committed Mar 26, 2017
1 parent 86d599c commit 8990536
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion builtin/providers/openstack/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8990536

Please sign in to comment.