Ring-log js

Ring logger

What is it?

A ring logger is a log systèm for production software that keeps the log messages in a ring buffer, which can be dumped when interesting circumstances arrise.

The particularity of this one is that it’s pure javascript, and dumps as a ‘POST’ request to a url. This allows for much improved debugging of js-rich web pages, whilst not filling up the web browsers memory with useless logs.

It depends on ToutouJS but doesn’t have a lot of calls, so it should be easilly portable if anyone finds the need.

Usage

First off, you have to include the relevent files:

<script src="js/toutou/toutou.js" type="text/javascript"><!--mce:0--></script>
<script src="ring_log.js" type="text/javascript"><!--mce:1--></script>

Then you just log away (the mores the better):

js.ring_log.log(js.ring_log.DEBUG,'Test','Test message');

Finally, to retrieve your log, ie dump the buffer:

js.ring_log.dump();

Et voila!

For testing purposes, the logger is pre-configured to call a script log.php in the same directory as it is in, and has a buffer size of 10, both parameters changeable in the source. The different parts of the log messages are seperated by a ’splitter’, by default ‘==|==’, this is also configurable.

js.ring_log.requestUri='log.php';
js.ring_log.log_data_size=10;
js.ring_log.splitter='==|==';

Patches,ideas and bugs to d.mills-ringlogjs AT guesny DOT net, flames to /dev/null

Download