fvlogger.js is a fine logging system for Javascript, but when you are already using Prototype.js, it unnecessarily duplicates a lot of functionality. I’ve forked the original code to “fvlogger 1.0.proto”, removing this duplication. In addition, I’ve added a sweet “add the logger to the page” function to the script. The end result is much smaller and cleaner looking than the original, I think.
This script is based on fvlogger 1.0, available from Five Volt Logic. It requires prototype, and if you want to use its auto-insertion features, it requires Behaviour.js as well. If you aren’t already using the Behaviour library, you should. It will revolutionize your use of Javascript, fully separating user interaction from markup. Most times I use it, I never have to use a single line of inline javascript at all. That is incredibly liberating!
If you want to use Prototype 1.3.x, you will also need to load a few functions borrowed from “the future”, which I’ve helpfully included as “prototype_future.js”. Just look at the test page in the zip, and all should be clear.
Download protologger-1.0.zip and let me know what you think.
Technorati Tags: javascript, libraries, prototype, logging, fvlogger, behaviour
















2 responses so far ↓
1 steve // Apr 12, 2006 at 11:36 pm
Be sure to try out jsTracer as well. On top of logging it provides a stack viewer and allows you to highlight messages, very useful for debugging cross broswer issues in complex script. It won’t cause slow script warnings even when tracing loads of recursive calls. It my favorite JavaScript logger at the moment.
http://jstracer.sourceforge.net/
2 Anonymous // Jun 30, 2006 at 7:21 pm
Or if you’re an event:Selectors ( http://encytemedia.com/event-selectors/ )kind of guy…
— logger.js.orig 2006-06-30 22:17:59.000000000 -0500
+++ logger.js 2006-06-30 22:19:57.000000000 -0500
@@ -6,7 +6,7 @@
Extended by Bruce Kroeze for Invisiblecastle.com
Wrapped all functionality in “Logger” toplevel var
- Trimmed some duplicate functionality, requires Prototype & Behaviour library
+ Trimmed some duplicate functionality, requires Prototype & event:Selectors library
*/
var Logger = {
// version number
@@ -176,12 +176,12 @@
},
showLogger : function () {
- if (typeof Behaviour == ‘undefined’) {
- throw(”ProtoLogger requires the Behaviour Library.”);
+ if (typeof EventSelectors == ‘undefined’) {
+ throw(”ProtoLogger (e:S version) requires the event:Selectors Library.”);
}
else {
document.write(’Loggeralltracedebuginfowarnerrorfatalerase‘);
- Behaviour.register(Logger.logrules);
+ EventSelectors.start(Logger.logrules);
}
}
}
Leave a Comment