Yet another JavaScript logger

While writing Beginning Google Maps Applications, I grew accustomed to using GLog.write() while debugging any JavaScript I was working on. It was a wonderful alternative to alert(). That was great while I was working on map related projects but without the Google Maps API, it wasn’t there. Finally the other day, frustrated the 100th time I accidentally put my browser into an infinite alert loop, I decided to write up a quick logger myself. Afterwards, I realized there were already a bunch on the net but I had fun writing my own and even learned a few DOM tricks. For any of you out there who want to use it, go nutz. I’ve called it JSLog and the primary methods are JSLog.write(); which outputs escaped angle brackets while JSLog.writeHTML() outputs the raw input.

JSLog Window

The best part is now when debugging things like Prototype AJAX calls, you can easily log and see all the exceptions!

new Ajax.Request( 'example.php', {
		try {
			//do whatever you need to an errors will be logged!
		} catch (e) {
			if(JSLog) JSLog.write(e);

No more errors floating into dream land!

To use it, just download the source or add

<script type="text/javascript" src="></script>

to the head of your document.