Support callstack formatting

This commit is contained in:
shortcutme 2016-09-05 13:53:40 +02:00
parent 25cb7d9ffa
commit b7dfeb139b
1 changed files with 11 additions and 1 deletions

View File

@ -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