Skip to content

Commit

Permalink
[Core][Logging] Add last frame information for better debugging (vllm…
Browse files Browse the repository at this point in the history
  • Loading branch information
youkaichao authored and alexeykondrat committed May 1, 2024
1 parent 2e580e8 commit a5bf497
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions vllm/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,27 @@ def _trace_calls(log_path, root_dir, frame, event, arg=None):
return
# Log every function call or return
try:
last_frame = frame.f_back
if last_frame is not None:
last_filename = last_frame.f_code.co_filename
last_lineno = last_frame.f_lineno
last_func_name = last_frame.f_code.co_name
else:
# initial frame
last_filename = ""
last_lineno = 0
last_func_name = ""
with open(log_path, 'a') as f:
if event == 'call':
f.write(f"{datetime.datetime.now()} Call to"
f" {func_name} in {filename}:{lineno}\n")
f" {func_name} in {filename}:{lineno}"
f" from {last_func_name} in {last_filename}:"
f"{last_lineno}\n")
else:
f.write(f"{datetime.datetime.now()} Return from"
f" {func_name} in {filename}:{lineno}\n")
f" {func_name} in {filename}:{lineno}"
f" to {last_func_name} in {last_filename}:"
f"{last_lineno}\n")
except NameError:
# modules are deleted during shutdown
pass
Expand Down

0 comments on commit a5bf497

Please sign in to comment.