|
19 | 19 | from urllib.parse import urlencode
|
20 | 20 |
|
21 | 21 | from influxdb_client.rest import ApiException
|
| 22 | +from influxdb_client.rest import _BaseRESTClient |
22 | 23 |
|
23 | 24 | try:
|
24 | 25 | import urllib3
|
@@ -164,6 +165,11 @@ def request(self, method, url, query_params=None, headers=None,
|
164 | 165 | if 'Content-Type' not in headers:
|
165 | 166 | headers['Content-Type'] = 'application/json'
|
166 | 167 |
|
| 168 | + if self.configuration.debug: |
| 169 | + _BaseRESTClient.log_request(method, f"{url}?{urlencode(query_params)}") |
| 170 | + _BaseRESTClient.log_headers(headers, '>>>') |
| 171 | + _BaseRESTClient.log_body(body, '>>>') |
| 172 | + |
167 | 173 | try:
|
168 | 174 | # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
169 | 175 | if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
|
@@ -239,6 +245,14 @@ def request(self, method, url, query_params=None, headers=None,
|
239 | 245 | # we need to decode it to string.
|
240 | 246 | r.data = r.data.decode('utf8')
|
241 | 247 |
|
| 248 | + if self.configuration.debug: |
| 249 | + _BaseRESTClient.log_response(r.status) |
| 250 | + if hasattr(r, 'headers'): |
| 251 | + _BaseRESTClient.log_headers(r.headers, '<<<') |
| 252 | + if hasattr(r, 'urllib3_response'): |
| 253 | + _BaseRESTClient.log_headers(r.urllib3_response.headers, '<<<') |
| 254 | + _BaseRESTClient.log_body(r.data, '<<<') |
| 255 | + |
242 | 256 | if not 200 <= r.status <= 299:
|
243 | 257 | raise ApiException(http_resp=r)
|
244 | 258 |
|
|
0 commit comments