4 ms·
> I've never understood why anyone would choose to debug by printing and logging if they have a good debugger available to them. Because logging provides a dif
by pkolaczk 3y ago
> I've never understood why anyone would choose to debug by printing and logging if they have a good debugger available to them.
Because logging provides a different experience and can be sometimes much faster. I can run the code once and then analyze all the collected information later. The log allows me to go back and forth very fast, or very quickly see that e.g. a 150th iteration went sideways even if I don't exactly know what to expect. Another area where logging is tremendously helpful is debugging concurrency related bugs.
- josephg 3y agoYep. Most debuggers also make it very hard to go backwards in time. Logs can be read in any order. There’s a neat trick I like to do when I’m trying to triage a bug that only shows up with some input data. I’ll run the passing test and the failing test with detailed logging, then diff the logs to understand how the code is behaving differently in each case.