Simplified logic for handlingConsoleRequests, Fixed Syntax Errors

This commit is contained in:
RayGervais 2017-03-16 18:27:19 -04:00 коммит произвёл David Humphrey
Родитель 8a4cf1436d
Коммит f198942856
2 изменённых файлов: 25 добавлений и 43 удалений

Просмотреть файл

@ -14,36 +14,13 @@ define(function (require, exports, module) {
function handleConsoleRequest(args, type) { function handleConsoleRequest(args, type) {
// Add an indentifier to the front of the args list // Add an indentifier to the front of the args list
args.unshift("[Bramble Console]:"); args.unshift("[Bramble Console]:");
switch(type) { // Time related arguments
case "log": if(type == "time" || type == "timeEnd") {
console.log.apply(console, args); args[0] = args[0] + " " + args[1];
break;
case "info":
console.info.apply(console, args);
break;
case "debug":
console.debug.apply(console, args);
break;
case "warn":
console.warn.apply(console, args);
break;
case "error":
console.error.apply(console, args);
break;
case "clear":
console.clear.apply(console);
break;
case "time":
args[0] = args[0] + " " + args[1];
console.time.apply(console, args);
break;
case "timeEnd":
args[0] = args[0] + " " + args[1];
console.timeEnd.apply(console, args);
break;
default:
} }
console[type].apply(console, args);
} }
exports.getRemoteScript = getRemoteScript; exports.getRemoteScript = getRemoteScript;

Просмотреть файл

@ -8,53 +8,58 @@
} }
} }
function generateRouter(fname) {
var args = Array.from(arguments).slice();
transportSend(args, fname);
}
// Implement console.log replacement // Implement console.log replacement
console.log = function() { console.log = function() {
var args = Array.from(arguments).slice(); var args = Array.from(arguments).slice();
transportSend(args, "log"); transportSend(args, "log");
}; };
// Implement console.debug replacement // Implement console.debug replacement
console.debug = function() { console.debug = function() {
var args = Array.from(arguments).slice(); var args = Array.from(arguments).slice();
transportSend(args, "debug"); transportSend(args, "debug");
}; };
// Implement console.error replacement // Implement console.error replacement
console.error = function() { console.error = function() {
var args = Array.from(arguments).slice(); var args = Array.from(arguments).slice();
transportSend(args, "error"); transportSend(args, "error");
} };
// Implement console.info replacement // Implement console.info replacement
console.info = function() { console.info = function() {
var args = Array.from(arguments).slice(); var args = Array.from(arguments).slice();
transportSend(args, "info"); transportSend(args, "info");
} };
// Implement console.info replacement // Implement console.warn replacement
console.warn = function() { console.warn = function() {
var args = Array.from(arguments).slice(); var args = Array.from(arguments).slice();
transportSend(args, "warn"); transportSend(args, "warn");
} };
// Implement console.clear replacement // Implement console.clear replacement
console.clear = function() { console.clear = function() {
var args = Array.from(arguments).slice(); var args = Array.from(arguments).slice();
transportSend(args, "clear"); transportSend(args, "clear");
} };
// Implement console.time replacement // Implement console.time replacement
console.time = function() { console.time = function() {
var args = Array.from(arguments).slice(); var args = Array.from(arguments).slice();
transportSend(args, "time"); transportSend(args, "time");
} };
// Implement console.time replacement // Implement console.timeEnd replacement
console.timeEnd = function() { console.timeEnd = function() {
var args = Array.from(arguments).slice(); var args = Array.from(arguments).slice();
transportSend(args, "timeEnd"); transportSend(args, "timeEnd");
} };
// Replace default console.assert with custom // Replace default console.assert with custom
console.assert = function() { console.assert = function() {