@jdeighan/coffee-utils 6.0.1 → 6.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/debug_utils.coffee +20 -16
- package/src/debug_utils.js +24 -18
package/package.json
CHANGED
package/src/debug_utils.coffee
CHANGED
@@ -28,6 +28,15 @@ export debugging = false
|
|
28
28
|
shouldDebug = shouldLog = undef
|
29
29
|
|
30
30
|
stack = new CallStack()
|
31
|
+
DEBUGDEBUG = false
|
32
|
+
|
33
|
+
# ---------------------------------------------------------------------------
|
34
|
+
|
35
|
+
export setDEBUGDEBUG = (flag=true) ->
|
36
|
+
|
37
|
+
DEBUGDEBUG = flag
|
38
|
+
console.log "DEBUGDEBUG = #{flag}"
|
39
|
+
return
|
31
40
|
|
32
41
|
# ---------------------------------------------------------------------------
|
33
42
|
|
@@ -36,8 +45,8 @@ export resetDebugging = (funcDoDebug=undef, funcDoLog=undef) ->
|
|
36
45
|
debugging = false
|
37
46
|
debugLevel = 0
|
38
47
|
stack.reset()
|
39
|
-
shouldDebug = (funcName
|
40
|
-
shouldLog = (str) -> debugging
|
48
|
+
shouldDebug = (funcName) -> debugging
|
49
|
+
shouldLog = (str) -> debugging
|
41
50
|
if funcDoDebug
|
42
51
|
setDebugging funcDoDebug, funcDoLog
|
43
52
|
return
|
@@ -47,15 +56,21 @@ export resetDebugging = (funcDoDebug=undef, funcDoLog=undef) ->
|
|
47
56
|
export setDebugging = (funcDoDebug=undef, funcDoLog=undef) ->
|
48
57
|
|
49
58
|
if isBoolean(funcDoDebug)
|
59
|
+
if DEBUGDEBUG
|
60
|
+
console.log "setDebugging #{funcDoDebug}"
|
50
61
|
debugging = funcDoDebug
|
51
62
|
else if isString(funcDoDebug)
|
52
63
|
debugging = false
|
53
64
|
lFuncNames = words(funcDoDebug)
|
54
65
|
assert isArray(lFuncNames), "words('#{funcDoDebug}') returned non-array"
|
55
|
-
shouldDebug = (funcName
|
56
|
-
|
66
|
+
shouldDebug = (funcName) ->
|
67
|
+
funcMatch(funcName, lFuncNames)
|
68
|
+
if DEBUGDEBUG
|
69
|
+
console.log "setDebugging FUNCS: #{lFuncNames.join(',')}"
|
57
70
|
else if isFunction(funcDoDebug)
|
58
71
|
shouldDebug = funcDoDebug
|
72
|
+
if DEBUGDEBUG
|
73
|
+
console.log "setDebugging to custom func"
|
59
74
|
else
|
60
75
|
croak "setDebugging(): bad parameter #{oneline(funcDoDebug)}"
|
61
76
|
|
@@ -114,17 +129,6 @@ getPrefix = (level) ->
|
|
114
129
|
|
115
130
|
# ---------------------------------------------------------------------------
|
116
131
|
|
117
|
-
envSaysDebug = (curFunc) ->
|
118
|
-
|
119
|
-
if process.env.DEBUG_FUNC?
|
120
|
-
return curFunc == process.env.DEBUG_FUNC
|
121
|
-
else if process.env.DEBUG_FUNCS?
|
122
|
-
return process.env.DEBUG_FUNCS.split(',').indexOf(curFunc) > -1
|
123
|
-
else
|
124
|
-
return false
|
125
|
-
|
126
|
-
# ---------------------------------------------------------------------------
|
127
|
-
|
128
132
|
export debug = (lArgs...) ->
|
129
133
|
# --- either 1 or 2 args
|
130
134
|
|
@@ -157,7 +161,7 @@ export debug = (lArgs...) ->
|
|
157
161
|
entering = true
|
158
162
|
curFunc = lMatches[1]
|
159
163
|
stack.call(curFunc, curEnv())
|
160
|
-
debugging =
|
164
|
+
debugging = shouldDebug(curFunc)
|
161
165
|
else if (lMatches = str.match(///^
|
162
166
|
\s*
|
163
167
|
return
|
package/src/debug_utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// Generated by CoffeeScript 2.6.1
|
2
2
|
// debug_utils.coffee
|
3
|
-
var arrow, arrowhead, corner, curEnv, debugLevel,
|
3
|
+
var DEBUGDEBUG, arrow, arrowhead, corner, curEnv, debugLevel, getPrefix, hbar, indent, logger, reMethod, setEnv, shouldDebug, shouldLog, stack, undef, vbar;
|
4
4
|
|
5
5
|
import {
|
6
6
|
assert,
|
@@ -63,16 +63,24 @@ shouldDebug = shouldLog = undef;
|
|
63
63
|
|
64
64
|
stack = new CallStack();
|
65
65
|
|
66
|
+
DEBUGDEBUG = false;
|
67
|
+
|
68
|
+
// ---------------------------------------------------------------------------
|
69
|
+
export var setDEBUGDEBUG = function(flag = true) {
|
70
|
+
DEBUGDEBUG = flag;
|
71
|
+
console.log(`DEBUGDEBUG = ${flag}`);
|
72
|
+
};
|
73
|
+
|
66
74
|
// ---------------------------------------------------------------------------
|
67
75
|
export var resetDebugging = function(funcDoDebug = undef, funcDoLog = undef) {
|
68
76
|
debugging = false;
|
69
77
|
debugLevel = 0;
|
70
78
|
stack.reset();
|
71
|
-
shouldDebug = function(funcName
|
72
|
-
return
|
79
|
+
shouldDebug = function(funcName) {
|
80
|
+
return debugging;
|
73
81
|
};
|
74
82
|
shouldLog = function(str) {
|
75
|
-
return debugging
|
83
|
+
return debugging;
|
76
84
|
};
|
77
85
|
if (funcDoDebug) {
|
78
86
|
setDebugging(funcDoDebug, funcDoLog);
|
@@ -83,16 +91,25 @@ export var resetDebugging = function(funcDoDebug = undef, funcDoLog = undef) {
|
|
83
91
|
export var setDebugging = function(funcDoDebug = undef, funcDoLog = undef) {
|
84
92
|
var lFuncNames;
|
85
93
|
if (isBoolean(funcDoDebug)) {
|
94
|
+
if (DEBUGDEBUG) {
|
95
|
+
console.log(`setDebugging ${funcDoDebug}`);
|
96
|
+
}
|
86
97
|
debugging = funcDoDebug;
|
87
98
|
} else if (isString(funcDoDebug)) {
|
88
99
|
debugging = false;
|
89
100
|
lFuncNames = words(funcDoDebug);
|
90
101
|
assert(isArray(lFuncNames), `words('${funcDoDebug}') returned non-array`);
|
91
|
-
shouldDebug = function(funcName
|
92
|
-
return
|
102
|
+
shouldDebug = function(funcName) {
|
103
|
+
return funcMatch(funcName, lFuncNames);
|
93
104
|
};
|
105
|
+
if (DEBUGDEBUG) {
|
106
|
+
console.log(`setDebugging FUNCS: ${lFuncNames.join(',')}`);
|
107
|
+
}
|
94
108
|
} else if (isFunction(funcDoDebug)) {
|
95
109
|
shouldDebug = funcDoDebug;
|
110
|
+
if (DEBUGDEBUG) {
|
111
|
+
console.log("setDebugging to custom func");
|
112
|
+
}
|
96
113
|
} else {
|
97
114
|
croak(`setDebugging(): bad parameter ${oneline(funcDoDebug)}`);
|
98
115
|
}
|
@@ -144,17 +161,6 @@ getPrefix = function(level) {
|
|
144
161
|
return ' '.repeat(level);
|
145
162
|
};
|
146
163
|
|
147
|
-
// ---------------------------------------------------------------------------
|
148
|
-
envSaysDebug = function(curFunc) {
|
149
|
-
if (process.env.DEBUG_FUNC != null) {
|
150
|
-
return curFunc === process.env.DEBUG_FUNC;
|
151
|
-
} else if (process.env.DEBUG_FUNCS != null) {
|
152
|
-
return process.env.DEBUG_FUNCS.split(',').indexOf(curFunc) > -1;
|
153
|
-
} else {
|
154
|
-
return false;
|
155
|
-
}
|
156
|
-
};
|
157
|
-
|
158
164
|
// ---------------------------------------------------------------------------
|
159
165
|
export var debug = function(...lArgs) {
|
160
166
|
var curFunc, entering, hInfo, item, itemPrefix, lMatches, nArgs, prefix, returning, str;
|
@@ -179,7 +185,7 @@ export var debug = function(...lArgs) {
|
|
179
185
|
entering = true;
|
180
186
|
curFunc = lMatches[1];
|
181
187
|
stack.call(curFunc, curEnv());
|
182
|
-
debugging =
|
188
|
+
debugging = shouldDebug(curFunc);
|
183
189
|
} else if ((lMatches = str.match(/^\s*return.+from\s+([A-Za-z_][A-Za-z0-9_\.]*)/))) {
|
184
190
|
returning = true;
|
185
191
|
curFunc = lMatches[1];
|