Skip to content

Commit 6560c89

Browse files
committed
Added cleaner function to debug framework activity.
1 parent 7f66313 commit 6560c89

File tree

20 files changed

+176
-178
lines changed

20 files changed

+176
-178
lines changed

mvcExpressLogger/com/mindscriptact/mvcExpressLogger/MvcExpressLogger.as

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import flash.events.KeyboardEvent;
1616
import flash.events.MouseEvent;
1717
import flash.utils.setTimeout;
1818
import org.mvcexpress.core.ModuleManager;
19+
import org.mvcexpress.core.namespace.pureLegsCore;
20+
import org.mvcexpress.core.traceObjects.TraceObj;
1921
import org.mvcexpress.MvcExpress;
2022

2123
/**
@@ -96,8 +98,8 @@ public class MvcExpressLogger {
9698
Style.LABEL_TEXT = 0xFFFFFF;
9799
}
98100

99-
MvcExpress.debugFunction = instance.debugMvcExpress;
100-
MvcExpress.loggerFunction = visualizerManager.logMvcExpress;
101+
use namespace pureLegsCore;
102+
MvcExpress.loggerFunction = instance.debugMvcExpress;
101103

102104
if (autoShow) {
103105
instance.showLogger();
@@ -120,56 +122,62 @@ public class MvcExpressLogger {
120122
}
121123
}
122124

123-
private function debugMvcExpress(msg:String):void {
124-
// TODO: refactor
125-
logText += msg + "\n";
125+
private function debugMvcExpress(traceObj:TraceObj):void {
126126
//
127-
if (isLogShown) {
128-
129-
var logType:String = msg.substr(0, 2);
127+
visualizerManager.logMvcExpress(traceObj);
128+
//
129+
if (traceObj.canPrint) {
130130

131-
if (logType == "##") {
132-
setTimeout(resolveCurrentModuleName, 1);
133-
} else {
134-
switch (currentTabButtonName) {
135-
case LOG_TAB:
136-
render();
137-
break;
138-
case MESSAGES_TAB:
139-
if (logType == "••" || logType == "•>") {
140-
if (!isRenderWaiting) {
141-
isRenderWaiting = true;
142-
setTimeout(render, 1);
131+
// TODO: refactor
132+
logText += traceObj + "\n";
133+
//
134+
if (isLogShown) {
135+
136+
var logType:String = String(traceObj).substr(0, 2);
137+
138+
if (logType == "##") {
139+
setTimeout(resolveCurrentModuleName, 1);
140+
} else {
141+
switch (currentTabButtonName) {
142+
case LOG_TAB:
143+
render();
144+
break;
145+
case MESSAGES_TAB:
146+
if (logType == "••" || logType == "•>") {
147+
if (!isRenderWaiting) {
148+
isRenderWaiting = true;
149+
setTimeout(render, 1);
150+
}
143151
}
144-
}
145-
break;
146-
case MEDIATORS_TAB:
147-
if (logType == "§§") {
148-
if (!isRenderWaiting) {
149-
isRenderWaiting = true;
150-
setTimeout(render, 1);
152+
break;
153+
case MEDIATORS_TAB:
154+
if (logType == "§§") {
155+
if (!isRenderWaiting) {
156+
isRenderWaiting = true;
157+
setTimeout(render, 1);
158+
}
151159
}
152-
}
153-
break;
154-
case PROXIES_TAB:
155-
if (logType == "¶¶") {
156-
if (!isRenderWaiting) {
157-
isRenderWaiting = true;
158-
setTimeout(render, 1);
160+
break;
161+
case PROXIES_TAB:
162+
if (logType == "¶¶") {
163+
if (!isRenderWaiting) {
164+
isRenderWaiting = true;
165+
setTimeout(render, 1);
166+
}
159167
}
160-
}
161-
break;
162-
case COMMANDS_TAB:
163-
if (logType == "©©") {
164-
if (!isRenderWaiting) {
165-
isRenderWaiting = true;
166-
setTimeout(render, 1);
168+
break;
169+
case COMMANDS_TAB:
170+
if (logType == "©©") {
171+
if (!isRenderWaiting) {
172+
isRenderWaiting = true;
173+
setTimeout(render, 1);
174+
}
167175
}
168-
}
169-
break;
170-
case VISUALIZER_TAB:
171-
break;
172-
default:
176+
break;
177+
case VISUALIZER_TAB:
178+
break;
179+
default:
180+
}
173181
}
174182
}
175183
}

mvcExpressLogger/com/mindscriptact/mvcExpressLogger/visualizer/VisualizerManager.as

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public class VisualizerManager {
153153
logObj.messageFromCommand = topObject.commandObject;
154154
} else {
155155
CONFIG::debug {
156-
throw Error("NOT HANDLED:" + logObj);
156+
//throw Error("NOT HANDLED:" + logObj);
157157
}
158158
}
159159
}
@@ -187,12 +187,12 @@ public class VisualizerManager {
187187
topObject = sendMessageStack.pop();
188188
if (logObj.type != topObject.type) {
189189
CONFIG::debug {
190-
throw Error("NOT HANDLED:" + logObj);
190+
//throw Error("NOT HANDLED:" + logObj);
191191
}
192192
} else {
193193
if (logObj.params != topObject.params) {
194194
CONFIG::debug {
195-
throw Error("NOT HANDLED:" + logObj);
195+
//throw Error("NOT HANDLED:" + logObj);
196196
}
197197
}
198198
}
@@ -209,23 +209,23 @@ public class VisualizerManager {
209209
// ALL IS GOOD...
210210
} else {
211211
CONFIG::debug {
212-
throw Error("NOT HANDLED:" + logObj);
212+
//throw Error("NOT HANDLED:" + logObj);
213213
}
214214
}
215215
}
216216
} else {
217217
CONFIG::debug {
218-
throw Error("NOT HANDLED:" + logObj);
218+
//throw Error("NOT HANDLED:" + logObj);
219219
}
220220
}
221221
} else {
222222
CONFIG::debug {
223-
throw Error("NOT HANDLED:" + logObj);
223+
//throw Error("NOT HANDLED:" + logObj);
224224
}
225225
}
226226
} else {
227227
CONFIG::debug {
228-
throw Error("NOT HANDLED:" + logObj);
228+
//throw Error("NOT HANDLED:" + logObj);
229229
}
230230
}
231231
break;
@@ -259,7 +259,7 @@ public class VisualizerManager {
259259
logObj.messageFromCommand = topObject.commandObject;
260260
} else {
261261
CONFIG::debug {
262-
throw Error("NOT HANDLED:" + logObj);
262+
//throw Error("NOT HANDLED:" + logObj);
263263
}
264264
}
265265
this.mvcExpressVisualizerScreen.drawMessageToMediator(logObj, l);
@@ -271,30 +271,30 @@ public class VisualizerManager {
271271
}
272272
} else {
273273
CONFIG::debug {
274-
throw Error("NOT HANDLED:" + logObj);
274+
//throw Error("NOT HANDLED:" + logObj);
275275
}
276276
}
277277
} else {
278278
CONFIG::debug {
279-
throw Error("NOT HANDLED:" + logObj);
279+
//throw Error("NOT HANDLED:" + logObj);
280280
}
281281
}
282282
} else {
283283
CONFIG::debug {
284-
throw Error("NOT HANDLED:" + logObj);
284+
//throw Error("NOT HANDLED:" + logObj);
285285
}
286286
}
287287
} else {
288288
CONFIG::debug {
289-
throw Error("NOT HANDLED:" + logObj);
289+
//throw Error("NOT HANDLED:" + logObj);
290290
}
291291
}
292292
}
293293
}
294294
break;
295295
default:
296296
CONFIG::debug {
297-
throw Error("NOT HANDLED:" + logObj);
297+
//throw Error("NOT HANDLED:" + logObj);
298298
}
299299
break;
300300
}

sampleProjects/com/mindScriptAct/mvcExpressVisualizer/VisualLoggerTestModule.as

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import flash.display.StageScaleMode;
2626
import flash.events.Event;
2727
import flash.geom.Point;
2828
import org.mvcexpress.modules.ModuleSprite;
29+
import org.mvcexpress.MvcExpress;
2930
import org.mvcexpress.utils.checkClassStringConstants;
3031

3132
/**
@@ -49,6 +50,7 @@ public class VisualLoggerTestModule extends ModuleSprite {
4950

5051
public function VisualLoggerTestModule() {
5152
CONFIG::debug {
53+
MvcExpress.debugFunction = trace;
5254
checkClassStringConstants(Msg, DataMsg, ViewMsg);
5355
MvcExpressLogger.init(this.stage, 600, 0, 900, 400, 1, true, MvcExpressLogger.VISUALIZER_TAB);
5456
}

src/org/mvcexpress/MvcExpress.as

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
package org.mvcexpress {
2+
import org.mvcexpress.core.namespace.pureLegsCore;
3+
import org.mvcexpress.core.traceObjects.TraceObj;
24

35
/**
46
* Class to store framework global settings and some important variables.
@@ -44,17 +46,40 @@ public class MvcExpress {
4446
*/
4547
static public var debugFunction:Function = null;
4648

47-
/**
48-
* Sets a logger function that will get framework activity messages as untiped Objects's.
49-
* ATTENTION : it will work only with compile variable CONFIG:debug set to true.
50-
*/
51-
static public var loggerFunction:Function = null;
52-
5349
/**
5450
* Flag to force sendMessageToAll function throw an error in debug mode.
5551
* (For people who don't what this feature in.)
5652
*/
5753
static public var disableSendToAllFeature:Boolean = false;
54+
55+
//----------------------------------
56+
// Internal
57+
//----------------------------------
58+
59+
/**
60+
* Function to get more detailed framework activity.
61+
* @private
62+
*/
63+
static pureLegsCore var loggerFunction:Function = null;
64+
65+
/**
66+
* Framework function for debugging.
67+
* @param traceObj
68+
* @private
69+
*/
70+
static pureLegsCore function debug(traceObj:TraceObj):void {
71+
CONFIG::debug {
72+
if (debugFunction != null) {
73+
if (traceObj.canPrint) {
74+
debugFunction(traceObj);
75+
}
76+
}
77+
use namespace pureLegsCore;
78+
if (loggerFunction != null) {
79+
loggerFunction(traceObj);
80+
}
81+
}
82+
}
5883

5984
}
6085
}

src/org/mvcexpress/core/CommandMap.as

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ public class CommandMap {
5252
use namespace pureLegsCore;
5353
// debug this action
5454
CONFIG::debug {
55-
if (MvcExpress.debugFunction != null) {
56-
MvcExpress.debugFunction(new TraceCommandMap_map("CommandMap.map", moduleName, type, commandClass));
57-
}
55+
use namespace pureLegsCore;
56+
MvcExpress.debug(new TraceCommandMap_map("CommandMap.map", moduleName, type, commandClass));
5857
validateCommandClass(commandClass);
5958
if (!Boolean(type) || type == "null" || type == "undefined") {
6059
throw Error("Message type:[" + type + "] can not be empty or 'null' or 'undefined'. (You are trying to map command:" + commandClass + ")");
@@ -76,9 +75,8 @@ public class CommandMap {
7675
public function unmap(type:String, commandClass:Class):void {
7776
// debug this action
7877
CONFIG::debug {
79-
if (MvcExpress.debugFunction != null) {
80-
MvcExpress.debugFunction(new TraceCommandMap_unmap("CommandMap.unmap", moduleName, type, commandClass));
81-
}
78+
use namespace pureLegsCore;
79+
MvcExpress.debug(new TraceCommandMap_unmap("CommandMap.unmap", moduleName, type, commandClass));
8280
}
8381
var commandList:Vector.<Class> = classRegistry[type];
8482
if (commandList) {
@@ -112,13 +110,9 @@ public class CommandMap {
112110

113111
// debug this action
114112
CONFIG::debug {
115-
if (MvcExpress.debugFunction != null) {
116-
MvcExpress.debugFunction(new TraceCommandMap_execute("CommandMap.execute", moduleName, command, commandClass, params));
117-
118-
}
119-
if (MvcExpress.loggerFunction != null) {
120-
MvcExpress.loggerFunction(new TraceCommandMap_execute("CommandMap.execute", moduleName, command, commandClass, params));
121-
}
113+
use namespace pureLegsCore;
114+
MvcExpress.debug(new TraceCommandMap_execute("CommandMap.execute", moduleName, command, commandClass, params));
115+
122116
validateCommandParams(commandClass, params);
123117
}
124118

@@ -163,12 +157,8 @@ public class CommandMap {
163157

164158
// debug this action
165159
CONFIG::debug {
166-
if (MvcExpress.debugFunction != null) {
167-
MvcExpress.debugFunction(new TraceCommandMap_handleCommandExecute("CommandMap.handleCommandExecute", moduleName, command, commandList[i], messageType, params));
168-
}
169-
if (MvcExpress.loggerFunction != null) {
170-
MvcExpress.loggerFunction(new TraceCommandMap_handleCommandExecute("CommandMap.handleCommandExecute", moduleName, command, commandList[i], messageType, params));
171-
}
160+
use namespace pureLegsCore;
161+
MvcExpress.debug(new TraceCommandMap_handleCommandExecute("CommandMap.handleCommandExecute", moduleName, command, commandList[i], messageType, params));
172162
}
173163

174164
use namespace pureLegsCore;

0 commit comments

Comments
 (0)