snoop
snoop copied to clipboard
Showing tracebacks
Sometimes you may want to see a traceback in the snoop logs when an exception is raised (right?). Some questions to consider:
- Should tracebacks sometimes/always show automatically, or only when they've been turned on? Should they be turned on in
snoop
,install
, or both? - Should they show whenever they are raised, or only when they end a call?
- Should they show in any traced call, including inner calls that are only traced because of a high
depth
, or only in functions directly traced with@snoop
orwith snoop
? - Should there be a function to log the traceback manually? This could be used even if there isn't an exception being handled, just to show the current stack. What should it be called?
- Should there be a function to log the traceback manually? This could be used even if there isn't an exception being handled, just to show the current stack. What should it be called?
That would be really useful. I quite often want to see, who called this function. Usually I just add assert False
or import traceback; traceback.print_stack()
if I don't know to break code execution.
So it would be nice, to have it integrated in snoop. I imagine it to look something like this:
@snoop(stack=True)
def foo(bar):
pass
Or with pp
:
def foo(bar):
pp(bar, stack=True)
Also it would be nice to filter stack trace, by giving list of package names, that you are interested in. For example:
pp(bar, stack=['snoop']
This would only show lines from snoop
package, ignoring everything else.
Agree with @sirex