Add setting to customize traceback frame locals reporting
This commit is contained in:
parent
dd76f79603
commit
37e2d404d3
@ -80,31 +80,41 @@ class print_traceback:
|
|||||||
_local.level -= 1
|
_local.level -= 1
|
||||||
return False # the outermost caller should handle this
|
return False # the outermost caller should handle this
|
||||||
|
|
||||||
|
variables = ["", None]
|
||||||
|
|
||||||
|
if _local.handler is None:
|
||||||
|
_local.handler = chain_exceptions(exc_value)
|
||||||
|
|
||||||
|
if var.TRACEBACK_VERBOSITY > 0:
|
||||||
|
word = "\nLocal variables from frame #{0} (in {1}):\n"
|
||||||
|
variables.append(None)
|
||||||
frames = []
|
frames = []
|
||||||
|
|
||||||
while tb is not None:
|
while tb is not None:
|
||||||
if tb.tb_frame.f_locals.get("_ignore_locals_") or not tb.tb_frame.f_locals:
|
if tb.tb_next is not None and tb.tb_frame.f_locals.get("_ignore_locals_") or not tb.tb_frame.f_locals:
|
||||||
frames.append(None)
|
frames.append(None)
|
||||||
else:
|
else:
|
||||||
frames.append(tb.tb_frame)
|
frames.append(tb.tb_frame)
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
|
|
||||||
if _local.handler is None:
|
if var.TRACEBACK_VERBOSITY < 2:
|
||||||
_local.handler = chain_exceptions(exc_value)
|
word = "Local variables from innermost frame (in {1}):\n"
|
||||||
|
frames = [frames[-1]]
|
||||||
variables = ["", None, None]
|
|
||||||
|
|
||||||
with _local.handler:
|
with _local.handler:
|
||||||
for i, frame in enumerate(frames, start=1):
|
for i, frame in enumerate(frames, start=1):
|
||||||
if frame is None:
|
if frame is None:
|
||||||
continue
|
continue
|
||||||
variables.append("\nLocal variables from frame #{0} (in {1}):\n".format(i, frame.f_code.co_name))
|
variables.append(word.format(i, frame.f_code.co_name))
|
||||||
for name, value in frame.f_locals.items():
|
for name, value in frame.f_locals.items():
|
||||||
variables.append("{0} = {1!r}".format(name, value))
|
variables.append("{0} = {1!r}".format(name, value))
|
||||||
|
|
||||||
if len(variables) > 3:
|
if len(variables) > 3:
|
||||||
variables.append("\n")
|
variables.append("\n")
|
||||||
|
if var.TRACEBACK_VERBOSITY > 1:
|
||||||
variables[2] = "Local variables in all frames (most recent call last):"
|
variables[2] = "Local variables in all frames (most recent call last):"
|
||||||
|
else:
|
||||||
|
variables[2] = ""
|
||||||
else:
|
else:
|
||||||
variables[2] = "No local variables found in all frames."
|
variables[2] = "No local variables found in all frames."
|
||||||
|
|
||||||
|
@ -204,6 +204,8 @@ DEV_CHANNEL = ""
|
|||||||
DEV_PREFIX = ""
|
DEV_PREFIX = ""
|
||||||
PASTEBIN_ERRORS = False
|
PASTEBIN_ERRORS = False
|
||||||
|
|
||||||
|
TRACEBACK_VERBOSITY = 2 # 0 = no locals at all, 1 = innermost frame's locals, 2 = all locals
|
||||||
|
|
||||||
# How often to ping the server (in seconds) to detect unclean disconnection
|
# How often to ping the server (in seconds) to detect unclean disconnection
|
||||||
SERVER_PING_INTERVAL = 120
|
SERVER_PING_INTERVAL = 120
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user