fix: Print the full json blob in debug mode

Related https://github.com/MISP/PyMISP/issues/462
pull/500/head
Raphaël Vinot 2019-11-15 13:59:51 +01:00
parent b1e50c8f6d
commit cd2995a212
1 changed files with 5 additions and 4 deletions

View File

@ -2193,10 +2193,6 @@ class ExpandedPyMISP(PyMISP):
kw_params: dict={}, output_type: str='json'):
'''Prepare a request for python-requests'''
url = urljoin(self.root_url, url)
if logger.isEnabledFor(logging.DEBUG):
logger.debug(f'{request_type} - {url}')
if data is not None:
logger.debug(data)
if data:
if not isinstance(data, str): # Else, we already have a text blob to send
if isinstance(data, dict): # Else, we can directly json encode.
@ -2204,6 +2200,11 @@ class ExpandedPyMISP(PyMISP):
data = {k: v for k, v in data.items() if v is not None}
data = json.dumps(data, default=pymisp_json_default)
if logger.isEnabledFor(logging.DEBUG):
logger.debug(f'{request_type} - {url}')
if data is not None:
logger.debug(data)
if kw_params:
# CakePHP params in URL
to_append_url = '/'.join([f'{k}:{v}' for k, v in kw_params.items()])