March 29th, 2006

JSLog — Unobtrusive JavaScript Logger

Linked off the FAQ for Firebug (another nice Firefox extension for debugging), I ran across JSLog. In short, it's a JavaScript library for unobtrusively adding logging to a page. The extension’s web page puts it this way:

Every language needs a System.out.println() or a Console.writeLine() — a quick and easy way to output messages to you, the developer, during development and testing. Historically, Javascript programmers have used alert() for this purpose. […] Safe to say that if you've done AJAX programming, you are sick of alert(). JSLog solves these problems! […]

Considering that I’m working on a webapp with heavy DOM Scripting, I think this’ll be just what I need:

  • It’s absolutely positioned, so it doesn’t affect the layout of the page
  • It can be enabled or disabled by setting a single variable, so debug statements can remain in scripts and appear only when needed
  • It supports several alert-levels (debug, warning, info, and error) to differentiate messages of varying severity

What’s also nice is that it’s pretty small — in minimized form, it’s just a box with a number in it (counting the number of messages in the console). I suppose it could be conceivably left enabled on a development server without getting in the way of other developers. I can’t wait to put this to use.

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>