From 198aebc32340b961cbcafbcff61e0610a6d6b1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Fri, 5 Jul 2013 14:06:02 -0300 Subject: Improve leap_assert traceback logging --- src/leap/common/check.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/leap/common/check.py b/src/leap/common/check.py index a2d39a6..e6b0b52 100644 --- a/src/leap/common/check.py +++ b/src/leap/common/check.py @@ -18,7 +18,6 @@ Set of functions to help checking situations """ -import inspect import logging import traceback @@ -39,9 +38,11 @@ def leap_assert(condition, message=""): if not condition: logger.error("Bug: %s" % (message,)) try: - frame = inspect.currentframe() - stack_trace = traceback.format_stack(frame) - logger.error(''.join(stack_trace)) + for formatted_line in traceback.format_list( + traceback.extract_stack()[:-1]): + for line in formatted_line.split("\n"): + if len(line.strip()) > 0: + logger.error(line) except Exception as e: logger.error("Bug in leap_assert: %r" % (e,)) assert condition, message -- cgit v1.2.3