4 ms·
I use debuggers usually for the stack trace. I use print's for most everything else. The reason is pretty simple - the print's customize the dump for the speci
by WalterBright 4y ago
I use debuggers usually for the stack trace.
I use print's for most everything else. The reason is pretty simple - the print's customize the dump for the specific problem I'm trying to track down. Using loggers generated far, far, far too much noise and not enough signal.
When the problem is found and fixed, I use `git diff` to find all the added debug logic, and delete it before checking in.
- diarrhea 4y agoSince branches and such are cheap, you might benefit from `git switch -c debug`, `git reset` etc. They can wipe your working tree clean instead of having to do it manually.
- WalterBright 4y agoI didn't know about that switch! thanks
- gugagore 4y agoThere are some cases where the smallest unit that the -p(atch) flag considers is not granular enough. In those cases, you can resort to manual editing. Even with that, I find it to be a huge timesaver.
- diarrhea 4y agoI suspect you already implicitly included it, but just to mention it: the hunks created by `--patch` commands can be split up further through `s`. But as you said, this is sometimes not enough either (two changed, adjacent lines will remain atomic).
- rhizome31 4y agoI don't know, in practice you'll also have useful changes that you want to keep. I usually resort to `git checkout -p` to get rid of the debugging statements.
- jffhn 4y ago>When the problem is found and fixed, I use `git diff` to find all the added debug logic I use "TODO" with a specific suffix to mark all the places in the code that are of interest for the work at hand (unfinished code, debug logs, places that might need modification, etc.), so that when I want to get a glimpse of what's left to deal with, a simple search for this mark yields all the places, and just them. Then once I think all the code to commit is ready, before doing the final diff review, I do a search for the mark and remove what's not to commit. It's much easier and safer that having to re-discover transient code through review, since you don't have to switch between review and edition for each cleanup, and you don't risk to miss some that would camouflage in a new chunk of code.