title: Conditionally print debug info containing sensitive data
body: <p>I am running a Go program as a <code>k8s</code> job.</p>
  <p>The application sends an API request to an <code>elasticsearch</code> cluster to <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-put-user.html" rel="nofollow noreferrer">create</a> users, therefore it will contain sensitive data (user's password).</p>
  <pre><code>    requestDump, err := httputil.DumpRequest(req, true)
      responseDump, err := httputil.DumpResponse(resp, true)
      esapiClient.log.Printf(&quot;got response code %d when creating user: %s\n&quot;, resp.StatusCode, user.Username)
      if resp.StatusCode != http.StatusOK {
          esapiClient.log.Printf(&quot;error: got response code: %d when creating user %s\n&quot;, resp.StatusCode, user.Username)
          esapiClient.log.Println(&quot;Request\n&quot;, string(requestDump))
          esapiClient.log.Println(&quot;Response\n&quot;, string(responseDump))
          return ErrResponseCode
      }
  </code></pre>
  <p>When things go south, I want to be able to dump the request and the responses (especially in <code>400</code> cases) to check what went wrong (mainly with potentially malformed requests).</p>
  <p>What is the recommended way of of doing this? Are log levels the only way around this?</p>