diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-09-04 01:46:18 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-09-04 01:46:18 +0000 |
commit | 93666bb84abc1edc36fbb3ef5ec194cf774e4826 (patch) | |
tree | 0664faf291a294d20ae09c18c70c1c703c13738c /swiftclient/utils.py | |
parent | ff073ab34a10230cc78a4daa3cab2e22bf1fd17d (diff) | |
parent | 3c0289844f73b9e685b8443c90b0ca80e0b18f28 (diff) | |
download | python-swiftclient-93666bb84abc1edc36fbb3ef5ec194cf774e4826.tar.gz |
Merge "Log and report trace on service operation fails"
Diffstat (limited to 'swiftclient/utils.py')
-rw-r--r-- | swiftclient/utils.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/swiftclient/utils.py b/swiftclient/utils.py index 8edfcfa..6ff6259 100644 --- a/swiftclient/utils.py +++ b/swiftclient/utils.py @@ -17,9 +17,9 @@ import hashlib import hmac import json import logging -import time - import six +import time +import traceback TRUE_VALUES = set(('true', '1', 'yes', 'on', 't', 'y')) EMPTY_ETAG = 'd41d8cd98f00b204e9800998ecf8427e' @@ -119,6 +119,20 @@ def parse_api_response(headers, body): return json.loads(body.decode(charset)) +def report_traceback(): + """ + Reports a timestamp and full traceback for a given exception. + + :return: Full traceback and timestamp. + """ + try: + formatted_lines = traceback.format_exc() + now = time.time() + return formatted_lines, now + except AttributeError: + return None, None + + class NoopMD5(object): def __init__(self, *a, **kw): pass |