@jdeighan/coffee-utils 7.0.58 → 7.0.59

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "7.0.58",
4
+ "version": "7.0.59",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -36,10 +36,9 @@ export class CallStack
36
36
 
37
37
  # ........................................................................
38
38
 
39
- enter: (funcName, oldFlag=undef) ->
39
+ enter: (funcName) ->
40
40
  # --- funcName might be <object>.<method>
41
41
 
42
- assert (oldFlag == undef), "enter() takes only 1 arg"
43
42
  if doDebugStack
44
43
  LOG "[--> ENTER #{funcName}]"
45
44
 
@@ -54,13 +53,13 @@ export class CallStack
54
53
  [_, ident1, ident2] = lMatches
55
54
  if ident2
56
55
  @lStack.push({
57
- fullName: "#{ident1}.#{ident2}"
56
+ fullName: funcName # "#{ident1}.#{ident2}"
58
57
  funcName: ident2
59
58
  isLogged: false
60
59
  })
61
60
  else
62
61
  @lStack.push({
63
- fullName: ident1
62
+ fullName: funcName
64
63
  funcName: ident1
65
64
  isLogged: false
66
65
  })
@@ -68,6 +67,12 @@ export class CallStack
68
67
 
69
68
  # ........................................................................
70
69
 
70
+ getLevel: () ->
71
+
72
+ return @level
73
+
74
+ # ........................................................................
75
+
71
76
  isLogging: () ->
72
77
 
73
78
  if (@lStack.length == 0)
@@ -86,12 +91,17 @@ export class CallStack
86
91
 
87
92
  # ........................................................................
88
93
 
89
- logCurFunc: () ->
94
+ logCurFunc: (funcName) ->
90
95
 
91
96
  # --- funcName must be the current function
92
97
  # and the isLogged flag must currently be false
98
+
93
99
  cur = @lStack[@lStack.length - 1]
94
100
  assert (cur.isLogged == false), "isLogged is already true"
101
+ if (funcName != cur.fullName)
102
+ LOG "cur func #{cur.fullName} is not #{funcName}"
103
+ LOG @dump()
104
+ croak "BAD"
95
105
  cur.isLogged = true
96
106
  @level += 1
97
107
  return
@@ -126,12 +136,6 @@ export class CallStack
126
136
 
127
137
  # ........................................................................
128
138
 
129
- getLevel: () ->
130
-
131
- return @level
132
-
133
- # ........................................................................
134
-
135
139
  curFunc: () ->
136
140
 
137
141
  if (@lStack.length == 0)
@@ -151,7 +155,6 @@ export class CallStack
151
155
  return false
152
156
 
153
157
  # ........................................................................
154
- # ........................................................................
155
158
 
156
159
  dump: (prefix='', label='CALL STACK') ->
157
160
 
@@ -162,3 +165,18 @@ export class CallStack
162
165
  for item, i in @lStack
163
166
  lLines.push " #{i}: #{item.fullName} #{item.isLogged}"
164
167
  return lLines.join("\n") + "\n"
168
+
169
+ # ........................................................................
170
+
171
+ sdump: (label='CALL STACK') ->
172
+
173
+ lFuncNames = []
174
+ for item in @lStack
175
+ if item.isLogged
176
+ lFuncNames.push '*' + item.fullName
177
+ else
178
+ lFuncNames.push item.fullName
179
+ if @lStack.length == 0
180
+ return "#{label} <EMPTY>"
181
+ else
182
+ return "#{label} #{lFuncNames.join(' ')}"
package/src/call_stack.js CHANGED
@@ -45,10 +45,9 @@ export var CallStack = class CallStack {
45
45
  }
46
46
 
47
47
  // ........................................................................
48
- enter(funcName, oldFlag = undef) {
48
+ enter(funcName) {
49
49
  var _, ident1, ident2, lMatches;
50
50
  // --- funcName might be <object>.<method>
51
- assert(oldFlag === undef, "enter() takes only 1 arg");
52
51
  if (doDebugStack) {
53
52
  LOG(`[--> ENTER ${funcName}]`);
54
53
  }
@@ -57,19 +56,24 @@ export var CallStack = class CallStack {
57
56
  [_, ident1, ident2] = lMatches;
58
57
  if (ident2) {
59
58
  this.lStack.push({
60
- fullName: `${ident1}.${ident2}`,
59
+ fullName: funcName, // "#{ident1}.#{ident2}"
61
60
  funcName: ident2,
62
61
  isLogged: false
63
62
  });
64
63
  } else {
65
64
  this.lStack.push({
66
- fullName: ident1,
65
+ fullName: funcName,
67
66
  funcName: ident1,
68
67
  isLogged: false
69
68
  });
70
69
  }
71
70
  }
72
71
 
72
+ // ........................................................................
73
+ getLevel() {
74
+ return this.level;
75
+ }
76
+
73
77
  // ........................................................................
74
78
  isLogging() {
75
79
  if (this.lStack.length === 0) {
@@ -89,12 +93,17 @@ export var CallStack = class CallStack {
89
93
  }
90
94
 
91
95
  // ........................................................................
92
- logCurFunc() {
96
+ logCurFunc(funcName) {
93
97
  var cur;
94
98
  // --- funcName must be the current function
95
99
  // and the isLogged flag must currently be false
96
100
  cur = this.lStack[this.lStack.length - 1];
97
101
  assert(cur.isLogged === false, "isLogged is already true");
102
+ if (funcName !== cur.fullName) {
103
+ LOG(`cur func ${cur.fullName} is not ${funcName}`);
104
+ LOG(this.dump());
105
+ croak("BAD");
106
+ }
98
107
  cur.isLogged = true;
99
108
  this.level += 1;
100
109
  }
@@ -128,11 +137,6 @@ export var CallStack = class CallStack {
128
137
  }
129
138
  }
130
139
 
131
- // ........................................................................
132
- getLevel() {
133
- return this.level;
134
- }
135
-
136
140
  // ........................................................................
137
141
  curFunc() {
138
142
  if (this.lStack.length === 0) {
@@ -157,7 +161,6 @@ export var CallStack = class CallStack {
157
161
  return false;
158
162
  }
159
163
 
160
- // ........................................................................
161
164
  // ........................................................................
162
165
  dump(prefix = '', label = 'CALL STACK') {
163
166
  var i, item, j, lLines, len, ref;
@@ -174,4 +177,24 @@ export var CallStack = class CallStack {
174
177
  return lLines.join("\n") + "\n";
175
178
  }
176
179
 
180
+ // ........................................................................
181
+ sdump(label = 'CALL STACK') {
182
+ var item, j, lFuncNames, len, ref;
183
+ lFuncNames = [];
184
+ ref = this.lStack;
185
+ for (j = 0, len = ref.length; j < len; j++) {
186
+ item = ref[j];
187
+ if (item.isLogged) {
188
+ lFuncNames.push('*' + item.fullName);
189
+ } else {
190
+ lFuncNames.push(item.fullName);
191
+ }
192
+ }
193
+ if (this.lStack.length === 0) {
194
+ return `${label} <EMPTY>`;
195
+ } else {
196
+ return `${label} ${lFuncNames.join(' ')}`;
197
+ }
198
+ }
199
+
177
200
  };
@@ -16,11 +16,12 @@ import {
16
16
  log, logItem, LOG, shortEnough, dashes,
17
17
  } from '@jdeighan/coffee-utils/log'
18
18
 
19
- callStack = new CallStack()
20
-
21
19
  # --- set in resetDebugging() and setDebugging()
20
+ export callStack = new CallStack()
22
21
  export shouldLog = () -> undef
23
- export lFuncList = []
22
+
23
+ lFuncList = []
24
+ strFuncList = undef # original string
24
25
 
25
26
  # --- internal debugging
26
27
  doDebugDebug = false
@@ -28,6 +29,13 @@ lFunctions = undef # --- only used when doDebugDebug is true
28
29
 
29
30
  # ---------------------------------------------------------------------------
30
31
 
32
+ export dumpCallStack = (label) ->
33
+
34
+ LOG callStack.dump('', label)
35
+ return
36
+
37
+ # ---------------------------------------------------------------------------
38
+
31
39
  export setDebugDebugging = (value=true) ->
32
40
  # --- value can be a boolean or string of words
33
41
 
@@ -42,58 +50,72 @@ export setDebugDebugging = (value=true) ->
42
50
 
43
51
  # ---------------------------------------------------------------------------
44
52
 
45
- logif = (label, lObjects...) ->
53
+ debugDebug = (label, lObjects...) ->
54
+ # --- For debugging functions in this module
46
55
 
47
56
  if ! doDebugDebug
48
57
  return
49
58
 
59
+ # --- At this point, doDebugDebug is true
60
+ doDebugDebug = false # temp - reset before returning
61
+
50
62
  assert isString(label), "1st arg #{OL(label)} should be a string"
51
63
  nObjects = lObjects.length
52
64
  [type, funcName] = getType(label, nObjects)
53
65
 
54
- level = callStack.getLevel()
55
- prefix = getPrefix(level)
56
- itemPrefix = removeLastVbar(prefix)
57
- sep = dashes(itemPrefix, 40)
66
+ switch type
67
+ when 'enter'
68
+ assert defined(funcName), "type enter, funcName = undef"
69
+ callStack.enter funcName
70
+ doLog = (lFunctions == undef) || (funcName in lFunctions)
58
71
 
59
- if (type == 'enter')
60
- if defined(lFunctions) && (funcName not in lFunctions)
61
- return
62
- callStack.enter funcName
63
- else if (type == 'return')
64
- if defined(lFunctions) && (funcName not in lFunctions)
65
- return
72
+ when 'return'
73
+ assert defined(funcName), "type return, funcName = undef"
74
+ doLog = (lFunctions == undef) || (funcName in lFunctions)
66
75
 
67
- doTheLogging type, label, lObjects
76
+ when 'string'
77
+ assert (funcName == undef), "type string, funcName defined"
78
+ assert (nObjects == 0), "Objects not allowed for #{OL(type)}"
79
+ doLog = true
68
80
 
69
- if (type == 'return')
81
+ when 'objects'
82
+ assert (funcName == undef), "type objects, funcName defined"
83
+ assert (nObjects > 0), "Objects required for #{OL(type)}"
84
+ dolog = true
85
+
86
+ if doLog
87
+ doTheLogging type, label, lObjects
88
+
89
+ if (type == 'enter') && doLog
90
+ callStack.logCurFunc(funcName)
91
+ else if (type == 'return')
70
92
  callStack.returnFrom funcName
71
93
 
94
+ doDebugDebug = true
72
95
  return
73
96
 
74
97
  # ---------------------------------------------------------------------------
75
98
 
76
99
  export debug = (label, lObjects...) ->
77
100
 
78
- logif "enter debug(#{OL(label)})", lObjects...
79
-
80
101
  assert isString(label), "1st arg #{OL(label)} should be a string"
81
102
 
82
- # --- We want to allow objects to be undef. Therefore, we need to
83
- # distinguish between 1 arg sent vs. 2 or more args sent
103
+ # --- If label is "enter <funcname>, we need to put that on the stack
104
+ # BEFORE we do any internal logging
84
105
  nObjects = lObjects.length
85
-
86
- # --- funcName is only set for types 'enter' and 'return'
87
106
  [type, funcName] = getType(label, nObjects)
88
- logif "type = #{OL(type)}"
89
- logif "funcName = #{OL(funcName)}"
107
+ if (type == 'enter')
108
+ callStack.enter funcName
109
+
110
+ debugDebug "enter debug(#{OL(label)})", lObjects...
111
+ debugDebug "type = #{OL(type)}"
112
+ debugDebug "funcName = #{OL(funcName)}"
90
113
 
91
114
  # --- function shouldLog() returns the (possibly modified) label
92
115
  # if we should log this, else it returns undef
93
116
 
94
117
  switch type
95
118
  when 'enter'
96
- callStack.enter funcName
97
119
  label = shouldLog(label, type, funcName, callStack)
98
120
  when 'return'
99
121
  label = shouldLog(label, type, funcName, callStack)
@@ -109,18 +131,21 @@ export debug = (label, lObjects...) ->
109
131
  assert (label == undef) || isString(label),
110
132
  "label not a string: #{OL(label)}"
111
133
  doLog = defined(label)
112
- logif "doLog = #{OL(doLog)}"
113
- logif "#{nObjects} objects"
134
+ debugDebug "doLog = #{OL(doLog)}"
135
+ debugDebug "#{nObjects} objects"
114
136
 
115
137
  if doLog
116
138
  doTheLogging type, label, lObjects
117
139
 
118
140
  if (type == 'enter') && doLog && (label.indexOf('call') == -1)
119
- callStack.logCurFunc()
120
- else if (type == 'return')
141
+ callStack.logCurFunc(funcName)
142
+
143
+ # --- This must be called BEFORE we return from funcName
144
+ debugDebug "return from debug()"
145
+
146
+ if (type == 'return')
121
147
  callStack.returnFrom funcName
122
148
 
123
- logif "return from debug()"
124
149
  return true # allow use in boolean expressions
125
150
 
126
151
  # ---------------------------------------------------------------------------
@@ -133,11 +158,11 @@ export doTheLogging = (type, label, lObjects) ->
133
158
  sep = dashes(itemPrefix, 40)
134
159
  assert isString(sep), "sep is not a string"
135
160
 
136
- logif "callStack", callStack
137
- logif "level = #{OL(level)}"
138
- logif "prefix = #{OL(prefix)}"
139
- logif "itemPrefix = #{OL(itemPrefix)}"
140
- logif "sep = #{OL(sep)}"
161
+ debugDebug "callStack", callStack
162
+ debugDebug "level = #{OL(level)}"
163
+ debugDebug "prefix = #{OL(prefix)}"
164
+ debugDebug "itemPrefix = #{OL(itemPrefix)}"
165
+ debugDebug "sep = #{OL(sep)}"
141
166
 
142
167
  switch type
143
168
  when 'enter'
@@ -183,13 +208,12 @@ export stdShouldLog = (label, type, funcName, stack) ->
183
208
  assert funcName == undef, "func name #{OL(funcName)} not undef"
184
209
  assert stack instanceof CallStack, "not a call stack object"
185
210
 
186
- logif "stdShouldLog(#{OL(label)}, #{OL(type)}, #{OL(funcName)}, stack)"
187
- logif "stack", stack
188
- logif "lFuncList", lFuncList
211
+ debugDebug "enter stdShouldLog(#{OL(label)}, #{OL(type)}, #{OL(funcName)}, stack)"
189
212
 
190
213
  switch type
191
214
  when 'enter'
192
- if funcMatch(stack, lFuncList)
215
+ if funcMatch()
216
+ debugDebug "return #{OL(label)} from stdShouldLog() - funcMatch"
193
217
  return label
194
218
 
195
219
  else
@@ -199,10 +223,14 @@ export stdShouldLog = (label, type, funcName, stack) ->
199
223
 
200
224
  prevLogged = stack.isLoggingPrev()
201
225
  if prevLogged
202
- return label.replace('enter', 'call')
226
+ result = label.replace('enter', 'call')
227
+ debugDebug "return #{OL(result)} from stdShouldLog() - s/enter/call/"
228
+ return result
203
229
  else
204
- if funcMatch(stack, lFuncList)
230
+ if funcMatch()
231
+ debugDebug "return #{OL(label)} from stdShouldLog()"
205
232
  return label
233
+ debugDebug "return undef from stdShouldLog()"
206
234
  return undef
207
235
 
208
236
  # ---------------------------------------------------------------------------
@@ -229,6 +257,7 @@ export setDebugging = (option) ->
229
257
 
230
258
  export getFuncList = (str) ->
231
259
 
260
+ strFuncList = str # store original string for debugging
232
261
  lFuncList = []
233
262
  for word in words(str)
234
263
  if lMatches = word.match(///^
@@ -258,23 +287,23 @@ export getFuncList = (str) ->
258
287
  # ---------------------------------------------------------------------------
259
288
  # --- export only to allow unit tests
260
289
 
261
- export funcMatch = (stack, lFuncList) ->
290
+ export funcMatch = () ->
262
291
 
263
292
  assert isArray(lFuncList), "not an array #{OL(lFuncList)}"
264
293
 
265
- curFunc = stack.curFunc()
266
- logif "funcMatch(): curFunc = #{OL(curFunc)}"
267
- logif stack.dump(' ')
268
- logif 'lFuncList', lFuncList
294
+ debugDebug "enter funcMatch()"
295
+ curFunc = callStack.curFunc()
296
+ debugDebug "curFunc = #{OL(curFunc)}"
297
+ debugDebug "lFuncList = #{strFuncList}"
269
298
  for h in lFuncList
270
299
  {name, object, plus} = h
271
300
  if (name == curFunc)
272
- logif " curFunc in lFuncList - match successful"
301
+ debugDebug "return from funcMatch() - curFunc in lFuncList"
273
302
  return true
274
- if plus && stack.isActive(name)
275
- logif " func #{OL(name)} is active - match successful"
303
+ if plus && callStack.isActive(name)
304
+ debugDebug "return from funcMatch() - func #{OL(name)} is active"
276
305
  return true
277
- logif " - no match"
306
+ debugDebug "return from funcMatch() - no match"
278
307
  return false
279
308
 
280
309
  # ---------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
2
  // debug_utils.coffee
3
- var callStack, doDebugDebug, lFunctions, logif, reMethod,
3
+ var debugDebug, doDebugDebug, lFuncList, lFunctions, reMethod, strFuncList,
4
4
  indexOf = [].indexOf;
5
5
 
6
6
  import {
@@ -51,14 +51,17 @@ import {
51
51
  dashes
52
52
  } from '@jdeighan/coffee-utils/log';
53
53
 
54
- callStack = new CallStack();
55
-
56
54
  // --- set in resetDebugging() and setDebugging()
55
+ export var callStack = new CallStack();
56
+
57
57
  export var shouldLog = function() {
58
58
  return undef;
59
59
  };
60
60
 
61
- export var lFuncList = [];
61
+ lFuncList = [];
62
+
63
+ strFuncList = undef; // original string
64
+
62
65
 
63
66
  // --- internal debugging
64
67
  doDebugDebug = false;
@@ -66,6 +69,11 @@ doDebugDebug = false;
66
69
  lFunctions = undef; // --- only used when doDebugDebug is true
67
70
 
68
71
 
72
+ // ---------------------------------------------------------------------------
73
+ export var dumpCallStack = function(label) {
74
+ LOG(callStack.dump('', label));
75
+ };
76
+
69
77
  // ---------------------------------------------------------------------------
70
78
  export var setDebugDebugging = function(value = true) {
71
79
  // --- value can be a boolean or string of words
@@ -80,51 +88,65 @@ export var setDebugDebugging = function(value = true) {
80
88
  };
81
89
 
82
90
  // ---------------------------------------------------------------------------
83
- logif = function(label, ...lObjects) {
84
- var funcName, itemPrefix, level, nObjects, prefix, sep, type;
91
+ debugDebug = function(label, ...lObjects) {
92
+ var doLog, dolog, funcName, nObjects, type;
85
93
  if (!doDebugDebug) {
86
94
  return;
87
95
  }
96
+ // --- At this point, doDebugDebug is true
97
+ doDebugDebug = false; // temp - reset before returning
88
98
  assert(isString(label), `1st arg ${OL(label)} should be a string`);
89
99
  nObjects = lObjects.length;
90
100
  [type, funcName] = getType(label, nObjects);
91
- level = callStack.getLevel();
92
- prefix = getPrefix(level);
93
- itemPrefix = removeLastVbar(prefix);
94
- sep = dashes(itemPrefix, 40);
95
- if (type === 'enter') {
96
- if (defined(lFunctions) && (indexOf.call(lFunctions, funcName) < 0)) {
97
- return;
98
- }
99
- callStack.enter(funcName);
100
- } else if (type === 'return') {
101
- if (defined(lFunctions) && (indexOf.call(lFunctions, funcName) < 0)) {
102
- return;
103
- }
101
+ switch (type) {
102
+ case 'enter':
103
+ assert(defined(funcName), "type enter, funcName = undef");
104
+ callStack.enter(funcName);
105
+ doLog = (lFunctions === undef) || (indexOf.call(lFunctions, funcName) >= 0);
106
+ break;
107
+ case 'return':
108
+ assert(defined(funcName), "type return, funcName = undef");
109
+ doLog = (lFunctions === undef) || (indexOf.call(lFunctions, funcName) >= 0);
110
+ break;
111
+ case 'string':
112
+ assert(funcName === undef, "type string, funcName defined");
113
+ assert(nObjects === 0, `Objects not allowed for ${OL(type)}`);
114
+ doLog = true;
115
+ break;
116
+ case 'objects':
117
+ assert(funcName === undef, "type objects, funcName defined");
118
+ assert(nObjects > 0, `Objects required for ${OL(type)}`);
119
+ dolog = true;
104
120
  }
105
- doTheLogging(type, label, lObjects);
106
- if (type === 'return') {
121
+ if (doLog) {
122
+ doTheLogging(type, label, lObjects);
123
+ }
124
+ if ((type === 'enter') && doLog) {
125
+ callStack.logCurFunc(funcName);
126
+ } else if (type === 'return') {
107
127
  callStack.returnFrom(funcName);
108
128
  }
129
+ doDebugDebug = true;
109
130
  };
110
131
 
111
132
  // ---------------------------------------------------------------------------
112
133
  export var debug = function(label, ...lObjects) {
113
134
  var doLog, funcName, nObjects, type;
114
- logif(`enter debug(${OL(label)})`, ...lObjects);
115
135
  assert(isString(label), `1st arg ${OL(label)} should be a string`);
116
- // --- We want to allow objects to be undef. Therefore, we need to
117
- // distinguish between 1 arg sent vs. 2 or more args sent
136
+ // --- If label is "enter <funcname>, we need to put that on the stack
137
+ // BEFORE we do any internal logging
118
138
  nObjects = lObjects.length;
119
- // --- funcName is only set for types 'enter' and 'return'
120
139
  [type, funcName] = getType(label, nObjects);
121
- logif(`type = ${OL(type)}`);
122
- logif(`funcName = ${OL(funcName)}`);
140
+ if (type === 'enter') {
141
+ callStack.enter(funcName);
142
+ }
143
+ debugDebug(`enter debug(${OL(label)})`, ...lObjects);
144
+ debugDebug(`type = ${OL(type)}`);
145
+ debugDebug(`funcName = ${OL(funcName)}`);
123
146
  // --- function shouldLog() returns the (possibly modified) label
124
147
  // if we should log this, else it returns undef
125
148
  switch (type) {
126
149
  case 'enter':
127
- callStack.enter(funcName);
128
150
  label = shouldLog(label, type, funcName, callStack);
129
151
  break;
130
152
  case 'return':
@@ -140,17 +162,19 @@ export var debug = function(label, ...lObjects) {
140
162
  }
141
163
  assert((label === undef) || isString(label), `label not a string: ${OL(label)}`);
142
164
  doLog = defined(label);
143
- logif(`doLog = ${OL(doLog)}`);
144
- logif(`${nObjects} objects`);
165
+ debugDebug(`doLog = ${OL(doLog)}`);
166
+ debugDebug(`${nObjects} objects`);
145
167
  if (doLog) {
146
168
  doTheLogging(type, label, lObjects);
147
169
  }
148
170
  if ((type === 'enter') && doLog && (label.indexOf('call') === -1)) {
149
- callStack.logCurFunc();
150
- } else if (type === 'return') {
171
+ callStack.logCurFunc(funcName);
172
+ }
173
+ // --- This must be called BEFORE we return from funcName
174
+ debugDebug("return from debug()");
175
+ if (type === 'return') {
151
176
  callStack.returnFrom(funcName);
152
177
  }
153
- logif("return from debug()");
154
178
  return true; // allow use in boolean expressions
155
179
  };
156
180
 
@@ -163,11 +187,11 @@ export var doTheLogging = function(type, label, lObjects) {
163
187
  itemPrefix = removeLastVbar(prefix);
164
188
  sep = dashes(itemPrefix, 40);
165
189
  assert(isString(sep), "sep is not a string");
166
- logif("callStack", callStack);
167
- logif(`level = ${OL(level)}`);
168
- logif(`prefix = ${OL(prefix)}`);
169
- logif(`itemPrefix = ${OL(itemPrefix)}`);
170
- logif(`sep = ${OL(sep)}`);
190
+ debugDebug("callStack", callStack);
191
+ debugDebug(`level = ${OL(level)}`);
192
+ debugDebug(`prefix = ${OL(prefix)}`);
193
+ debugDebug(`itemPrefix = ${OL(itemPrefix)}`);
194
+ debugDebug(`sep = ${OL(sep)}`);
171
195
  switch (type) {
172
196
  case 'enter':
173
197
  log(label, {prefix});
@@ -212,7 +236,7 @@ export var doTheLogging = function(type, label, lObjects) {
212
236
 
213
237
  // ---------------------------------------------------------------------------
214
238
  export var stdShouldLog = function(label, type, funcName, stack) {
215
- var prevLogged;
239
+ var prevLogged, result;
216
240
  // --- if type is 'enter', then funcName won't be on the stack yet
217
241
  // returns the (possibly modified) label to log
218
242
 
@@ -227,12 +251,11 @@ export var stdShouldLog = function(label, type, funcName, stack) {
227
251
  assert(funcName === undef, `func name ${OL(funcName)} not undef`);
228
252
  }
229
253
  assert(stack instanceof CallStack, "not a call stack object");
230
- logif(`stdShouldLog(${OL(label)}, ${OL(type)}, ${OL(funcName)}, stack)`);
231
- logif("stack", stack);
232
- logif("lFuncList", lFuncList);
254
+ debugDebug(`enter stdShouldLog(${OL(label)}, ${OL(type)}, ${OL(funcName)}, stack)`);
233
255
  switch (type) {
234
256
  case 'enter':
235
- if (funcMatch(stack, lFuncList)) {
257
+ if (funcMatch()) {
258
+ debugDebug(`return ${OL(label)} from stdShouldLog() - funcMatch`);
236
259
  return label;
237
260
  } else {
238
261
  // --- As a special case, if we enter a function where we will not
@@ -240,15 +263,19 @@ export var stdShouldLog = function(label, type, funcName, stack) {
240
263
  // we'll log out the call itself
241
264
  prevLogged = stack.isLoggingPrev();
242
265
  if (prevLogged) {
243
- return label.replace('enter', 'call');
266
+ result = label.replace('enter', 'call');
267
+ debugDebug(`return ${OL(result)} from stdShouldLog() - s/enter/call/`);
268
+ return result;
244
269
  }
245
270
  }
246
271
  break;
247
272
  default:
248
- if (funcMatch(stack, lFuncList)) {
273
+ if (funcMatch()) {
274
+ debugDebug(`return ${OL(label)} from stdShouldLog()`);
249
275
  return label;
250
276
  }
251
277
  }
278
+ debugDebug("return undef from stdShouldLog()");
252
279
  return undef;
253
280
  };
254
281
 
@@ -279,6 +306,7 @@ export var setDebugging = function(option) {
279
306
  // --- export only to allow unit tests
280
307
  export var getFuncList = function(str) {
281
308
  var _, ident1, ident2, j, lMatches, len, plus, ref, word;
309
+ strFuncList = str; // store original string for debugging
282
310
  lFuncList = [];
283
311
  ref = words(str);
284
312
  for (j = 0, len = ref.length; j < len; j++) {
@@ -306,26 +334,26 @@ export var getFuncList = function(str) {
306
334
 
307
335
  // ---------------------------------------------------------------------------
308
336
  // --- export only to allow unit tests
309
- export var funcMatch = function(stack, lFuncList) {
337
+ export var funcMatch = function() {
310
338
  var curFunc, h, j, len, name, object, plus;
311
339
  assert(isArray(lFuncList), `not an array ${OL(lFuncList)}`);
312
- curFunc = stack.curFunc();
313
- logif(`funcMatch(): curFunc = ${OL(curFunc)}`);
314
- logif(stack.dump(' '));
315
- logif('lFuncList', lFuncList);
340
+ debugDebug("enter funcMatch()");
341
+ curFunc = callStack.curFunc();
342
+ debugDebug(`curFunc = ${OL(curFunc)}`);
343
+ debugDebug(`lFuncList = ${strFuncList}`);
316
344
  for (j = 0, len = lFuncList.length; j < len; j++) {
317
345
  h = lFuncList[j];
318
346
  ({name, object, plus} = h);
319
347
  if (name === curFunc) {
320
- logif(" curFunc in lFuncList - match successful");
348
+ debugDebug("return from funcMatch() - curFunc in lFuncList");
321
349
  return true;
322
350
  }
323
- if (plus && stack.isActive(name)) {
324
- logif(` func ${OL(name)} is active - match successful`);
351
+ if (plus && callStack.isActive(name)) {
352
+ debugDebug(`return from funcMatch() - func ${OL(name)} is active`);
325
353
  return true;
326
354
  }
327
355
  }
328
- logif(" - no match");
356
+ debugDebug("return from funcMatch() - no match");
329
357
  return false;
330
358
  };
331
359