UsableTypeTypography for the World Wide Web

weblog

Introducing RSLog

Remote Script Logging (RSLog) is a MIT Licensed, light-weight, and easily customisable script which allows you to catch and trace JavaScript errors occuring on your users’ machines by logging them back to your web server.

It is completely unobtrusive, adds only one reference to the browser’s global namespace, and weighs in at just 660 bytes when minified. Check out the demo page.

Using RSLog

To use RSLog simply include the core JavaScript file near the top of your document and begin logging by executing RSLog.start().

Of course the script needs to talk to something on the server. This can be in what ever language most suits your needs, but I have created a very basic PHP script that logs to a text file. The simplest way to start using RSLog is to download the gzipped archive (containing the JavaScript, PHP, and log file) and unzip to your web server.

Options

The RSLog.start() method excepts one optional argument. This is an object of configuration parameters as shown below.

  • suppress - Boolean to suppress errors being passed to browsers default error handling. Default: true
  • url - Full URL to send errors to. Default: /rslog/rslog.php on current host.
RSLog.start( { suppress: false, url: 'http://example.com/rslog/log.asp' } )

Supported browsers

To remain unobtrusive the script uses the window.onerror event handler to catch errors. This event is only supported by IE 4+ and Gecko based browsers, including Firefox, Camino and Mozilla. It is not supported by Safari or Opera, so you won’t be able to catch errors specific to those browsers.

Comments:

On 4 Apr 07

Bramus! (contact, colleague) said:

Going to give this one a spin. Surely will come in handy! Tnx!

On 26 Apr 07

mark said:

Seems pretty useful. I'll probably give it a try as well.

On 27 Jul 07

Dewi Morgan said:

Would you object if I made a Drupal module around this? [Drupal's a CMS which allows functionality to be added by "modules".]

To be included in the Drupal module archive, modules must be GPL licensed. MIT is apparently "GPL compatible", but that just means an MIT author's licensing decision can be parasitically embraced and extinguished by GPL. I'd rather respect and retain your licensing decision, so I'd dual license the module as "MIT or GPL".

If you feel that GPL is sufficiently abhorrent that you'd rather your stuff isn't included in a GPL'd module, I fully understand, and will release it only under the MIT license, from my homepage, rather than the official Drupal module archive.

If you'd rather that no Drupal module's distributed at all, I'm fine with that, too!

Add your comment:

Got an OpenID?

Latest Links

Joe finds me patronising! Arsenalski Niet

To get in touch, please use the UT form below.

Name:
Email:
Message:

close