Interesting project, though I'd suggest losing the line about "can't be bothered to set one up right now" regarding a full debugger. (i)pdb is built in and is simple to use. Perhaps focus on what this can add rather than framing the project as something like a lazy alternative (especially when this may actually be harder to set up than throwing in "import pdb; pdb.set_trace()")? edit: spelling
I’d also lose the profanity. > You can use it in your shitty, sprawling enterprise codebase without having to do any setup. Debugging is a sensitive subject, particularly given how frustrating it can be. There’s a place for vulgarity somewhere, but I’d rather see your README provide authoritative info than crack jokes.
PySnooper: Never use print for debugging again
11–20 of 175 posts
Re: PySnooper: Never use print for debugging again
#12Re: PySnooper: Never use print for debugging again
#13Will it work with multiprocessing?
Good question. If the function is launched in a spawned process, it'll work, though you might have trouble getting the stderr, so you better include a log file as the first argument, like this `@snoop('/var/log/snoop.log')` If the function launches new processes internally... I'm not sure. If you try it and it doesn't work, open an issue: https://github.com/cool-RR/PySnooper/issues
Re: PySnooper: Never use print for debugging again
#14I have to say sometimes I do find it much easier to read logs than to muck about in an interactive interpreter. That said I did just add `export PYTHONBREAKPOINT=pudb.set_trace` to my bashrc and am slowly going through and removing all my old `from IPython import embed` lines. A much simpler workflow that doesn't incur major runtime costs.
Re: PySnooper: Never use print for debugging again
#15Interesting project, though I'd suggest losing the line about "can't be bothered to set one up right now" regarding a full debugger. (i)pdb is built in and is simple to use. Perhaps focus on what this can add rather than framing the project as something like a lazy alternative (especially when this may actually be harder to set up than throwing in "import pdb; pdb.set_trace()")? edit: spelling
Re: PySnooper: Never use print for debugging again
#16that gonna be huge chunk of log to search
No, because by default it only logs what's happening directly in your function, not what happens deeper in the stack. (i.e. functions that your function calls.) You can set depth=2 or depth=3 and then you'll get a huge chunk of log. The deeper levels will be indented.
Re: PySnooper: Never use print for debugging again
#17Earlier quoted context omitted.
No, because by default it only logs what's happening directly in your function, not what happens deeper in the stack. (i.e. functions that your function calls.) You can set depth=2 or depth=3 and then you'll get a huge chunk of log. The deeper levels will be indented.
Does it have an option to print the caller ? "u" is my fav cmd in pdb.
Re: PySnooper: Never use print for debugging again
#18Presumably it works with Django? If yes then thrice thanks.
This project would justify an additional dedicated screen just for dumping function debug logs.
Re: PySnooper: Never use print for debugging again
#19I love this concept and will definitely be using it. Presumably it works with Django? If yes then thrice thanks. This project would justify an additional dedicated screen just for dumping function debug logs.
Re: PySnooper: Never use print for debugging again
#20Earlier quoted context omitted.
Good question. If the function is launched in a spawned process, it'll work, though you might have trouble getting the stderr, so you better include a log file as the first argument, like this `@snoop('/var/log/snoop.log')` If the function launches new processes internally... I'm not sure. If you try it and it doesn't work, open an issue: https://github.com/cool-RR/PySnooper/issues
There is a race condition when writting on the same log file from several processes at the same time, which is a typical use case for wsgi frameworks such as django or flask.