improve debugging function
authorWolfram Schneider <wosch@indexdata.dk>
Fri, 21 Jun 2013 10:25:23 +0000 (10:25 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Fri, 21 Jun 2013 10:25:23 +0000 (10:25 +0000)
for debug=2 display caller function
for debug=3 display full dump

experiments/spclient/index.html
experiments/spclient/mkws.js

index e9f32ad..65d44a6 100644 (file)
@@ -10,7 +10,7 @@
     <script type="text/javascript">
        var mkws_config = { 
                lang: "en",
-               debug: 1,
+               debug: 2,
                use_service_proxy: true,
                switch: true, 
                sort_default: "relevance",
index 7067296..f14fcf8 100644 (file)
@@ -1,7 +1,7 @@
 /* A very simple client that shows a basic usage of the pz2.js
 */
 
-"use strict"; // HTML5
+// "use strict"; // HTML5
 
 if (!mkws_config)
     var mkws_config = {}; // for the guys who forgot to define mkws_config...
@@ -661,7 +661,13 @@ function debug(string) {
     if (!console) { /* ARGH!!! */
        return;
     }
-    
+
+    // you need to disable use strict at the top of the file!!!
+    if (mkws_debug >= 3) {
+       console.log(arguments.callee.caller);
+    } else if (mkws_debug >= 2) {
+       console.log(">>> called from function " + arguments.callee.caller.name + ' <<<');
+    }
     console.log(string);
 }