Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Table of Contents (17 chapters)
JavaScript at Scale
About the Author
About the Reviewers

Logging and debugging

Part of coping with failure in a large-scale JavaScript application is producing the right information. The most obvious place to start is the error console, where uncaught exceptions are logged, or just plain error messages generated using console.error(). Some error messages lead to quick fixes, while others send programmers on a wild goose chase.

Apart from logging errors as they happen, we might also want to log situations where something erroneous is about to happen. These are warning messages and they're not used as much as they should be in frontend applications. Warnings are especially useful in diagnosing the more insidious problems with our code, as they leave a trail of clues in the wake of a failure.

The user doesn't necessarily see these logs if they don't have their developer tools window open, and the average user probably doesn't. Instead, we only show them the errors that are relevant to what they're doing in the application. Therefore, we can't just...