utils.debug.trace_lines: Improve output
This commit is contained in:
parent
b56df7c955
commit
c04ad1de45
@ -27,7 +27,7 @@ from functools import wraps
|
|||||||
|
|
||||||
from PyQt5.QtCore import pyqtRemoveInputHook, QEvent, QCoreApplication
|
from PyQt5.QtCore import pyqtRemoveInputHook, QEvent, QCoreApplication
|
||||||
|
|
||||||
from qutebrowser.utils.misc import elide
|
from qutebrowser.utils.misc import elide, compact_text
|
||||||
from qutebrowser.utils.log import misc as logger
|
from qutebrowser.utils.log import misc as logger
|
||||||
import qutebrowser.commands.utils as cmdutils
|
import qutebrowser.commands.utils as cmdutils
|
||||||
|
|
||||||
@ -106,15 +106,19 @@ def trace_lines(do_trace):
|
|||||||
Args:
|
Args:
|
||||||
do_trace: Whether to start tracing (True) or stop it (False).
|
do_trace: Whether to start tracing (True) or stop it (False).
|
||||||
"""
|
"""
|
||||||
def trace(frame, event, _):
|
def trace(frame, event, arg):
|
||||||
"""Trace function passed to sys.settrace.
|
"""Trace function passed to sys.settrace.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
Itself, so tracing continues.
|
Itself, so tracing continues.
|
||||||
"""
|
"""
|
||||||
if sys is not None:
|
if sys is not None:
|
||||||
print("{}, {}:{}".format(event, frame.f_code.co_filename,
|
loc = '{}:{}'.format(frame.f_code.co_filename, frame.f_lineno)
|
||||||
frame.f_lineno), file=sys.stderr)
|
if arg is not None:
|
||||||
|
arg = compact_text(str(arg), 200)
|
||||||
|
else:
|
||||||
|
arg = ''
|
||||||
|
print("{:11} {:80} {}".format(event, loc, arg), file=sys.stderr)
|
||||||
return trace
|
return trace
|
||||||
else:
|
else:
|
||||||
# When tracing while shutting down, it seems sys can be None
|
# When tracing while shutting down, it seems sys can be None
|
||||||
|
Loading…
Reference in New Issue
Block a user