Logs as a thinking tool
A log is not just text output. It is a way to structure thinking when facing a bug.
Before writing a log, it often helps to clearly define what needs to be verified.
Providing context
An isolated log is rarely enough. Context around the value is often what makes it meaningful.
- where the code runs
- under which conditions
- what happened just before
Avoiding disposable logs
Logs added in a rush tend to stay. Over time, they lose meaning and clutter the console.
As discussed in the console.log article, removing logs is part of the job.
Logs and method
Well thought-out logs often make heavier tools unnecessary.
They naturally fit into a progressive debugging approach, like the one described in the previous article 🙂