The Logger component is a browser-safe, compressible way to log JavaScript events. The component provides a framework for printing log statements into the DOM, or using the native browser console system. Additionally, if you use YUI Compressor tool to minimize your JavaScript files, then all logger statements will be automatically removed from the minimized files. This allows you to pepper your files with useful debugging statements, and know that they will be removed from your production code. The first half of this chapter will show you recipes for using and formatting the Logger component.
The Test component provides a framework for testing your JavaScript code. You write test functions against your code, organizing them into test cases and suites, and execute your tests using a test runner. The test runner reports the success or failure of the test functions to a specialized LogReader. The latter half of this chapter will show you recipes for writing and running tests.