     |> Enum.map(fn {k, v} -> ["Query: ", to_string(k), ": ", to_string(v), ?\n] end)
   end
 
-  defp debug_headers([]), do: @debug_no_headers
-  defp debug_headers(headers), do: Enum.map(headers, fn {k, v} -> [k, ": ", v, ?\n] end)
+  defp debug_headers([], _opts), do: @debug_no_headers
+
+  defp debug_headers(headers, opts) do
+    filtered = Keyword.get(opts, :filter_headers)
+    filtered = if is_list(filtered), do: filtered, else: []
+
+    Enum.map(headers, fn {k, v} ->
+      v = if k in filtered, do: "[FILTERED]", else: v
+      [k, ": ", v, ?\n]
+    end)
+  end
 
   defp debug_body(nil), do: @debug_no_body
   defp debug_body([]), do: @debug_no_body


  defp debug_body(data) when is_binary(data) or is_list(data), do: data
  defp debug_body(term), do: inspect(term)

  defp filter_headers(env, []), do: env

  defp filter_headers(env, filter_headers) when is_list(filter_headers) do
    headers =
      env.headers
      |> Enum.map(fn {key, val} ->
        val = if key in filter_headers, do: "[FILTERED]", else: val
        {key, val}
      end)

    %Tesla.Env{env | headers: headers}
  end

  defp filter_headers(env, _), do: env
end

    Logger.log(level, fn -> Formatter.format(env, response, time, @format) end)

    if Keyword.get(@config, :debug, true) do
      Logger.debug(fn -> debug(env, response, opts) end)
    end

    response
