debug() will log with time stamp in milliseconds
authorWolfram Schneider <wosch@indexdata.dk>
Thu, 29 Aug 2013 13:16:59 +0000 (15:16 +0200)
committerWolfram Schneider <wosch@indexdata.dk>
Thu, 29 Aug 2013 13:16:59 +0000 (15:16 +0200)
tools/htdocs/mkws.js

index 144d2de..44a35a0 100644 (file)
@@ -78,6 +78,11 @@ mkws.locale_lang = {
     }
 };
 
+// keep time state for debugging
+mkws.debug_time = {
+    "start": $.now(),
+    "last": $.now()
+};
 mkws.debug = function (string) {
     if (!mkws.debug)
        return;
@@ -86,13 +91,17 @@ mkws.debug = function (string) {
        return;
     }
 
+    var now = $.now();
+    var timestamp = (now - mkws.debug_time.start)/1000 + " (+" + (now - mkws.debug_time.last)/1000 + ") "
+    mkws.debug_time.last = now;
+
     // you need to disable use strict at the top of the file!!!
     if (mkws.debug >= 3) {
-       console.log(arguments.callee.caller);
+       console.log(timestamp + arguments.callee.caller);
     } else if (mkws.debug >= 2) {
-       console.log(">>> called from function " + arguments.callee.caller.name + ' <<<');
+       console.log(timestamp + ">>> called from function " + arguments.callee.caller.name + ' <<<');
     }
-    console.log(string);
+    console.log(timestamp + string);
 }
 var debug = mkws.debug; // local alias