Skip to content

Commit

Permalink
improved debug for jSON based data/params
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Jul 14, 2020
1 parent fdb3dc1 commit a3bd103
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions CloudFlare/cloudflare.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,19 @@ def _call_network(self, method, headers, parts,
str(identifier2),
str(parts[2]),
str(identifier3))
self.logger.debug('Call: optional params and data %s %s',
str(params),
str(data))
if files:
if params is not None:
try:
str_params = json.dumps(params)
except:
str_params = str(params)
self.logger.debug('Call: params=%s', str_params)
if data is not None:
try:
str_data = json.dumps(data)
except:
str_data = str(data)
self.logger.debug('Call: data=%s', str_data)
if files is not None:
self.logger.debug('Call: upload file %r', files)

if (method is None) or (parts[0] is None):
Expand Down Expand Up @@ -207,8 +216,8 @@ def _call_network(self, method, headers, parts,
url += '/' + identifier3

if self.logger:
self.logger.debug('Call: method and url %s %s', str(method), str(url))
self.logger.debug('Call: headers %s', str(sanitize_secrets(headers)))
self.logger.debug('Call: method=%s url=%s', str(method), str(url))
self.logger.debug('Call: headers=%s', str(sanitize_secrets(headers)))

try:
if self.logger:
Expand All @@ -222,7 +231,7 @@ def _call_network(self, method, headers, parts,
raise CloudFlareAPIError(0, 'connection failed.')

if self.logger:
self.logger.debug('Response: url %s', response.url)
self.logger.debug('Response: url=%s', response.url)

# Create response_{type|code|data}
try:
Expand Down

0 comments on commit a3bd103

Please sign in to comment.