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

Feature request: Implement tool to explore long PySnooper outputs #176

Open
cool-RR opened this issue Jan 28, 2020 · 6 comments
Open

Feature request: Implement tool to explore long PySnooper outputs #176

cool-RR opened this issue Jan 28, 2020 · 6 comments

Comments

@cool-RR
Copy link
Owner

cool-RR commented Jan 28, 2020

It happened that I was using PySnooper with depth=10000 to explore a piece of running code. Of course, the output was huge with many levels of indentations. I wanted to explore it, but it was difficult to track the execution of a single function.

It would be cool if there was a tool that accepted PySnooper outputs and allow some useful use cases of exploring them to find what you want.

@cool-RR
Copy link
Owner Author

cool-RR commented Jan 28, 2020

Anyone who wants to implement this, we'll need to do a lot of work on defining the design and use cases before starting to implement.

@cxs-kge
Copy link

cxs-kge commented Jun 15, 2021

Until something is designed and implemented, I've written a small utility to convert pysnooper logs to html pages, with folds based on the indentation.

It's clearly not perfect as there is no syntaxic coloration, nor a way to search for a specific term in the page, but it's better than looking at all the logs manually.

https://gist.github.com/cxs-kge/689597fd216b0a64b5bf0c35354cd0b4

@cool-RR
Copy link
Owner Author

cool-RR commented Jun 15, 2021

Cool, thank you.

@martinsmid
Copy link

martinsmid commented Feb 17, 2022

I've been using this little script to strip and diff two pysnooper's outputs

sed -r 's/[0-9]+ |//' -i $1
sed -e 's/at 0x[a-z0-9]\+/at XXX/g' -i $1
sed -e 's/line [0-9]\+/line YYY/g' -i $1

Put it in a file like strip_snoop.sh and use with path to file strip_snoop.sh <file>.
I thought the normalize parameter would help now with the updated version.

I've put it into a gist if that helps and for updates

Btw. coloring has been added to output, but i wasn't able to disable it. I am investigating what's wrong with my setup, but I have at least few tips related to exploring outputs. I think diff is the tool to be used, if the output is stripped off undiffable data. normalize should help here but it doesn't seem to do what I wanted and also would consider automatically triggering color=False when using normalize and file output. I might put it into separate issues/feature request if I have time to explore what's really going on with the coloring now.

@martinsmid
Copy link

Sorry for spamming this thread, but I should mention I found the problem. I assumed the output file is always overwritten with new content, but it is appended by default. There doesn't seem to be a switch to change this behavior, so I am using snoop(open('<filepath>', 'w'), ...). Everything works now.

@cool-RR
Copy link
Owner Author

cool-RR commented Feb 22, 2022

Thanks Martin. Right now I don't have this need, but next time I'll have it I'll look into your scripts.

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

3 participants