Skip to content

Commit a7ee137

Browse files
author
Matt Karl
committed
Fixed remote trace of objects, colors and console subs
1 parent 8953513 commit a7ee137

File tree

7 files changed

+83
-33
lines changed

7 files changed

+83
-33
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.0-alpha.6",
3+
"version": "0.2.0-alpha.7",
44
"private": true,
55
"dependencies": {
66
"jqueryui": "*",

deploy/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@
4141
<span class="icon glyphicon glyphicon-send"></span> Remote Trace
4242
</a>
4343
</div>
44-
<footer class="version">Version <span id="version">0.2.0-alpha.6</span></footer>
44+
<footer class="version">Version <span id="version">0.2.0-alpha.7</span></footer>
4545
</body>
4646
</html>

deploy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SpringRollStudio",
33
"description": "Application for SpringRoll projects",
4-
"version": "0.2.0-alpha.6",
4+
"version": "0.2.0-alpha.7",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/SpringRoll/SpringRollStudio"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SpringRollStudio",
33
"private": true,
4-
"version": "0.2.0-alpha.6",
4+
"version": "0.2.0-alpha.7",
55
"dependencies": {
66
"grunt": "~0.4.5",
77
"grunt-contrib-copy": "^0.7.0",

project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.0-alpha.6",
3+
"version": "0.2.0-alpha.7",
44
"main": [
55
"components/node-webkit-app/src/utils/UpdateChecker.js",
66
"components/node-webkit-app/src/utils/Browser.js",

src/springroll/remote/RemoteTrace.js

Lines changed: 77 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -313,47 +313,56 @@
313313
atBottom = scrollTop + height >= scrollHeight;
314314

315315
result = JSON.parse(result);
316-
var level = result.level || "GENERAL";
317-
var now = (new Date()).toLocaleString();
318316

319-
// This is a hack we should fix the framework
320-
if (level === "true" || level === true)
321-
{
322-
level = "DE"+"BUG";
323-
}
317+
var level = (result.level || "GENERAL").toLowerCase();
318+
var now = (new Date()).toLocaleString();
324319

325320
this.saveButton.removeClass('disabled');
326321
this.clearButton.removeClass('disabled');
327322

328-
var log = $("<div class='log'></div>")
329-
.addClass(level.toLowerCase());
330-
331323
if (level === "session")
332324
{
333-
if (this.clearOnNewSession)
334-
{
335-
this.clear();
336-
}
337-
log.text("New Session Began at " + now);
325+
this.logSession(now);
338326
}
339-
else
327+
else if (Array.isArray(result.message))
340328
{
341-
var message = result.message;
329+
var message, i, j, tokens, token, sub;
342330

343-
if (typeof message === "object")
331+
for (i = 0; i < result.message.length; i++)
344332
{
345-
message = JSON.stringify(message, null, "\t");
333+
message = result.message[i];
334+
335+
// Ignore non-strings
336+
if (typeof message == "string")
337+
{
338+
tokens = message.match(/%[sdifoObxec]/g);
339+
340+
if (tokens)
341+
{
342+
for (j = 0; j < tokens.length; j++)
343+
{
344+
token = tokens[j];
345+
sub = result.message[++i];
346+
347+
// CSS substitution check
348+
if (token == "%c")
349+
{
350+
sub = '<span style="'+ sub + '">';
351+
message += '</span>';
352+
}
353+
// Do object substitution
354+
else if (token == "%o" || token == "%O")
355+
{
356+
sub = JSON.stringify(sub, null, "\t");
357+
}
358+
message = message.replace(token, String(sub));
359+
}
360+
}
361+
}
362+
this.logMessage(now, message, level);
346363
}
347-
log.append(
348-
$("<span class='type'></span>").text(level),
349-
$("<span class='timestamp'></span>").text(now),
350-
$("<span class='message'></span>").text(message)
351-
);
352364
}
353365

354-
// Add a new log
355-
this.output.append(log);
356-
357366
if (this.maxLogs)
358367
{
359368
this.output.html(this.output.children(".log").slice(-this.maxLogs));
@@ -366,6 +375,47 @@
366375
}
367376
};
368377

378+
/**
379+
* Log a new message
380+
* @method logMessage
381+
* @param {string} now The current time name
382+
* @param {string} message The message to log
383+
* @param {string} level The level to use
384+
*/
385+
p.logMessage = function(now, message, level)
386+
{
387+
if (typeof message === "object")
388+
{
389+
message = JSON.stringify(message, null, "\t");
390+
}
391+
this.output.append(
392+
$("<div class='log'></div>")
393+
.addClass(level)
394+
.append(
395+
$("<span class='type'></span>").text(level.toUpperCase()),
396+
$("<span class='timestamp'></span>").text(now),
397+
$("<span class='message'></span>").html(message)
398+
)
399+
);
400+
};
401+
402+
/**
403+
* Log a new session
404+
* @method logSession
405+
* @param {string} now The current time name
406+
*/
407+
p.logSession = function(now)
408+
{
409+
if (this.clearOnNewSession)
410+
{
411+
this.clear();
412+
}
413+
this.output.append(
414+
$("<div class='log session'></div>")
415+
.text("New Session Began at " + now)
416+
);
417+
};
418+
369419
/**
370420
* Close the application
371421
* @method shutdown

src/springroll/remote/less/trace.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
}
5252
// Options for the trace
5353
&.wrap .log {
54-
white-space:normal;
54+
white-space:pre;
5555
}
5656
&.timestamps .timestamp {
5757
display: inline-block;

0 commit comments

Comments
 (0)