Indent based on how many calls are currently being traced

This commit is contained in:
Alex Hall 2019-05-10 17:56:52 +02:00 committed by Ram Rachum
parent 1bcaea2059
commit 8f91784821
1 changed files with 7 additions and 4 deletions

View File

@ -246,6 +246,7 @@ class Tracer:
# or the user asked to go a few levels deeper and we're within that
# number of levels deeper.
depth = 0
if not (frame.f_code in self.target_codes or frame in self.target_frames):
if self.depth == 1:
# We did the most common and quickest check above, because the
@ -256,17 +257,19 @@ class Tracer:
return None
else:
_frame_candidate = frame
for i in range(1, self.depth):
for depth in range(1, self.depth):
_frame_candidate = _frame_candidate.f_back
if _frame_candidate is None:
return None
elif _frame_candidate.f_code in self.target_codes or _frame_candidate in self.target_frames:
indent = ' ' * 4 * i
break
else:
return None
else:
indent = ''
stack = self.thread_local.original_trace_functions
depth += len(stack) - 1
indent = ' ' * 4 * depth
# #
### Finished checking whether we should trace this line. ##############