From b7dfeb139be859a57bba258d41165b8b2df485d1 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Mon, 5 Sep 2016 13:53:40 +0200 Subject: [PATCH] Support callstack formatting --- src/Debug/Debug.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Debug/Debug.py b/src/Debug/Debug.py index 050adf4c..c7c0a3fd 100644 --- a/src/Debug/Debug.py +++ b/src/Debug/Debug.py @@ -1,6 +1,5 @@ import sys import os -import traceback from Config import config @@ -14,6 +13,7 @@ class Notify(Exception): def formatException(err=None, format="text"): + import traceback if type(err) == Notify: return err exc_type, exc_obj, exc_tb = sys.exc_info() @@ -29,6 +29,16 @@ def formatException(err=None, format="text"): else: return "%s: %s in %s" % (exc_type.__name__, err, " > ".join(tb)) +def formatStack(): + import inspect + back = [] + for stack in inspect.stack(): + frame, path, line, function, source, index = stack + file = os.path.split(path)[1] + back.append("%s line %s" % (file, line)) + return " > ".join(back) + + # Test if gevent eventloop blocks if config.debug_gevent: import logging