samuelcolvin / python-devtools

Dev tools for python
https://python-devtools.helpmanual.io/
MIT License
985 stars 47 forks source link

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

Open kalekundert opened 2 years ago

kalekundert commented 2 years ago

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 commented 2 years ago

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

I guess:

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 commented 2 years ago

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.