Skip to content

Commit 7e102e9

Browse files
committed
PYAPI-23 Common: More Verbose Logging When HTTP Status != 200
1 parent b3e6220 commit 7e102e9

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

PKG-INFO

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: atlassian-python-api
3-
Version: 0.6.3
3+
Version: 0.6.4
44
Author: Matt Harasymczuk
55
Author-email: code at mattagile com
66
Maintainer: Matt Harasymczuk

atlassian/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ def __init__(self, url, username, password):
1515
self.username = username
1616
self.password = password
1717

18-
def log_curl_debug(self, method, path, headers={}, data=None):
19-
command = "curl --silent -X {method} -u '{username}':'{password}' -H {headers} {data} '{url}'".format(
18+
def log_curl_debug(self, method, path, headers={}, data=None, level=logging.DEBUG):
19+
message = "curl --silent -X {method} -u '{username}':'{password}' -H {headers} {data} '{url}'".format(
2020
method=method,
2121
username=self.username,
2222
password=self.password,
2323
headers=' -H '.join(["'{0}: {1}'".format(key, value) for key, value in headers.items()]),
2424
data='' if not data else "--data '{0}'".format(json.dumps(data)),
2525
url='{0}{1}'.format(self.url, path))
26-
log.debug(command)
26+
log.log(level=level, msg=message)
2727

2828
def request(self, method='GET', path='/', headers={'Content-Type': 'application/json', 'Accept': 'application/json'}, data=None):
2929
self.log_curl_debug(method, path, headers, data)
@@ -34,6 +34,9 @@ def request(self, method='GET', path='/', headers={'Content-Type': 'application/
3434
data=json.dumps(data),
3535
auth=(self.username, self.password),
3636
timeout=60)
37+
if response.status_code != 200:
38+
self.log_curl_debug(method, path, headers, data, level=logging.WARNING)
39+
log.warning(response.json())
3740
response.raise_for_status()
3841
log.debug('Received: {0}'.format(response.json()))
3942
return response

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
name="atlassian-python-api",
99
description="Atlassian Python API",
1010
license="Apache License 2.0",
11-
version="0.6.3",
11+
version="0.6.4",
1212
download_url="https://github.com/MattAgile/atlassian-python-api",
1313

1414
author="Matt Harasymczuk",

0 commit comments

Comments
 (0)