aboutsummaryrefslogtreecommitdiffstats
path: root/uni/unimgr/dbg.js
diff options
context:
space:
mode:
Diffstat (limited to 'uni/unimgr/dbg.js')
-rw-r--r--uni/unimgr/dbg.js84
1 files changed, 84 insertions, 0 deletions
diff --git a/uni/unimgr/dbg.js b/uni/unimgr/dbg.js
new file mode 100644
index 0000000..f4d3416
--- /dev/null
+++ b/uni/unimgr/dbg.js
@@ -0,0 +1,84 @@
+(function(){
+
+ var dbgFlag = true;
+ var pre = ""
+
+ var on = function() { dbgFlag = true; };
+ var off = function() { dbgFlag = false; };
+
+ var p = function(str, tab) {
+ if ( dbgFlag )
+ {
+ var tabStr = "";
+ if (tab) {
+ for (var i = 0; i < tab; i++ )
+ tabStr += " ";
+ }
+ console.log(pre + tabStr + str);
+ }
+ };
+
+ var pj = function(obj) {
+ if ( dbgFlag )
+ console.log(JSON.stringify(obj,null,3)) ;
+ };
+
+ var e = function(eMsg) {
+ console.log("!! ERROR: " + eMsg);
+ }
+
+ var w = function(eMsg) {
+ console.log("** WARNIING: " + eMsg);
+ }
+
+ // for testing. Write regaurdless of dbgFlag
+ var t = function(str, tab) {
+ var tabStr = "";
+ if (tab) {
+ for (var i = 0; i < tab; i++ )
+ tabStr += " ";
+ }
+ console.log(pre + tabStr + str);
+ }
+
+function curTime() {
+
+ var date = new Date();
+
+ var hour = date.getHours();
+ hour = (hour < 10 ? "0" : "") + hour;
+
+ var min = date.getMinutes();
+ min = (min < 10 ? "0" : "") + min;
+
+ var sec = date.getSeconds();
+ sec = (sec < 10 ? "0" : "") + sec;
+
+ // var year = date.getFullYear();
+
+ // var month = date.getMonth() + 1;
+ // month = (month < 10 ? "0" : "") + month;
+
+ // var day = date.getDate();
+ // day = (day < 10 ? "0" : "") + day;
+
+ // return year + ":" + month + ":" + day + ":" + hour + ":" + min + ":" + sec;
+
+ return hour + ":" + min + ":" + sec;
+
+
+}
+
+ module.exports.curTime = curTime; // returns str w current time
+
+ module.exports.on = on; // enable DBG printing
+ module.exports.off = off; // squelch DBG printing
+ module.exports.p = p; // print a debug string
+ module.exports.pj = pj; // print JSON version of an object
+ module.exports.w = w; // print an warning msg
+ module.exports.e = e; // print an error msg
+ module.exports.t = t; // print an error msg
+
+
+
+}()); \ No newline at end of file