Bookmarklet Based Debugging
The reason this works for us is because we use a common logging infrastructure across our whole web app: MochiKit.Logging. This, and the rest of MochiKit, will be liberally licensed open source (likely MIT) in less than two weeks. MochiKit.Logging is vaguely similar to Python's logging module or Apache's log4j, but without all of the headaches and mindless configuration sludge.
Typical usage for our Logger object looks like this:
// these are global functions for convenience: log("some", "objects", "here", "at", "the", "INFO", "level"); logDebug("some", "objects", "here", "at", "the", "DEBUG", "level"); // or more generally: logger.baseLog(logLevel, objects...);
When one of these log methods are called, two things happen:
- Any attached listeners to the logger are notified (which may or may not do something interesting with the log message)
- The global logger stuffs the log message away in a log buffer (of configurable size, by default it's infinite) for easy retrieval
Listeners are really just for future enhancements (i.e. "real-time" log window by bookmarklet), but our current bookmarklet simply formats the last 40 messages or so as an alert message and spits it to the browser.