debug() will log with time stamp in milliseconds
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index 5db8b45..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
 
@@ -752,6 +761,7 @@ function mkws_service_proxy_auth(auth_url) {
        alert("HTTP call for authentication failed: " + err)
        return;
     });
+
     request.get(null, function(data) {
        if (!$.isXMLDoc(data)) {
            alert("service proxy auth response document is not valid XML document, give up!");
@@ -762,6 +772,9 @@ function mkws_service_proxy_auth(auth_url) {
            alert("service proxy auth repsonse status: " + status.text() + ", give up!");
            return;
        }
+
+       debug("Service proxy auth successfully done");
+       mkws.service_proxy_auth = true;
     });
 }