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

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