improve debugging function
[mkws-moved-to-github.git] / experiments / spclient / mkws.js
index daf222d..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...
@@ -506,7 +506,7 @@ function mkws_set_lang(mkws_config)  {
        mkws_config.lang = lang;
     }
     
-    debug("Locale language: " + mkws_config.lang);
+    debug("Locale language: " + (mkws_config.lang ? mkws_config.lang : "none"));
     return mkws_config.lang;
 }
 
@@ -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);
 }