Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Have you ever come up against an application that felt like it was built on sand? Maybe you've been tasked with creating an application that needs to last longer than a year before a complete re-write? If so, JavaScript at Scale is your missing documentation for maintaining scalable architectures. There's no prerequisite framework knowledge required for this book, however, most concepts presented throughout are adaptations of components found in frameworks such as Backbone, AngularJS, or Ember. All code examples are presented using ECMAScript 6 syntax, to make sure your applications are ready for next generation browsers.
Table of Contents (12 chapters)
11
Index

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...