From: Wolfram Schneider Date: Thu, 29 Aug 2013 13:16:59 +0000 (+0200) Subject: debug() will log with time stamp in milliseconds X-Git-Tag: 0.9.1~202^2~33 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=678d2261ad63016d4206716750537deb9ea242c6 debug() will log with time stamp in milliseconds --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 144d2de..44a35a0 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -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