Console Log Levels
One of the main reasons not to use console.log
is that the results can be overwhelming - leaving a log statement inside a loop can quickly cause all of your output to scroll away.
Other times, you may not be able to quickly distinguish between important logging output and basic diagnostics - especially if you are in the middle of development for a project.
You can use different logging levels in the console to easily filter your debugging or trace statements.
Starting at the top, with the most important level, we would have these different methods for the developer console:
console.error()
console.warn()
console.info()
Depending on which web browser you use, these may render in different ways. The video above this tip shows how these look in Google Chrome - you can filter down to just the levels you want to see. For the warning and error levels, you can expand the error next to the message to see where in the code the warning or error came from.