always log an error when api key is incorrect

This commit is contained in:
Alan Hamlett 2014-11-23 11:35:43 -08:00
parent d73ac29fa5
commit 7ddf028041
1 changed files with 12 additions and 0 deletions

View File

@ -286,6 +286,10 @@ def send_action(project=None, branch=None, stats=None, key=None, targetFile=None
auth = u('Basic {key}').format(key=u(base64.b64encode(str.encode(key) if is_py3 else key)))
request.add_header('Authorization', auth)
ALWAYS_LOG_CODES = [
401,
]
# add Olson timezone to request
try:
tz = tzlocal.get_localzone()
@ -310,6 +314,10 @@ def send_action(project=None, branch=None, stats=None, key=None, targetFile=None
queue.push(data, plugin)
if log.isEnabledFor(logging.DEBUG):
log.warn(exception_data)
if response.getcode() in ALWAYS_LOG_CODES:
log.error({
'response_code': response.getcode(),
})
else:
log.error(exception_data)
except:
@ -325,6 +333,10 @@ def send_action(project=None, branch=None, stats=None, key=None, targetFile=None
log.error(exception_data)
elif log.isEnabledFor(logging.DEBUG):
log.warn(exception_data)
if response.getcode() in ALWAYS_LOG_CODES:
log.error({
'response_code': response.getcode(),
})
else:
log.error(exception_data)
else: