snoop icon indicating copy to clipboard operation
snoop copied to clipboard

Showing tracebacks

Open alexmojaki opened this issue 5 years ago • 2 comments

Sometimes you may want to see a traceback in the snoop logs when an exception is raised (right?). Some questions to consider:

  1. Should tracebacks sometimes/always show automatically, or only when they've been turned on? Should they be turned on in snoop, install, or both?
  2. Should they show whenever they are raised, or only when they end a call?
  3. 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 or with snoop?
  4. 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?

alexmojaki avatar Jun 30 '19 20:06 alexmojaki

  1. 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.

sirex avatar Sep 04 '19 11:09 sirex

Agree with @sirex

TejasAvinashShetty avatar Dec 31 '19 10:12 TejasAvinashShetty