Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to include stack trace in debug() output? #105

Open
kalekundert opened this issue Jun 7, 2022 · 2 comments
Open

Option to include stack trace in debug() output? #105

kalekundert opened this issue Jun 7, 2022 · 2 comments

Comments

@kalekundert
Copy link

Today I was trying to debug an issue where a function of mine was unexpectedly being called from two places. I was using debug() within the function, but it only reports the file/line number/function that it was directly invoked from, which in this case I knew. I wanted to know where this function was being called from, so I looked for a way to get a full stack trace by doing something like debug(trace=True). As far as I can tell, this option doesn't exist yet.

Is there interest in adding such an option? If so, I could probably try to make a PR in the near-ish future.

@samuelcolvin
Copy link
Owner

Yes definitely, I often want this, just haven't had time to implement it.

I guess:

  • trace_ kwarg for debug to include the trace
  • debug.trace() to just print the traceback to the current position

Both should be highlighted I guess if pygments is installed, I seem to remember that pygments has a custom highlighting language for python tracebacks, but I might be wrong.

@kalekundert
Copy link
Author

That sounds like a good API to me. No promises that I'll get around to this super-soon, but good to know that a PR is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants