python-devtools
python-devtools copied to clipboard
Option to include stack trace in `debug()` output?
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.
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.
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.