Log: New logging system.

Right now, all I've done is move the logging function from utils to its own
file. I've also refactored it and created some classes.

Next step would be to somehow get rid of the trace setting. The Remote class
should have nothing to do with logging settings. Perhaps we can keep the setting
for backwards compatibility only, but the main way to turn logging on/off or
filter logging messages should be through the Log class.
This commit is contained in:
Stefan Thomas
2014-02-27 23:38:31 -08:00
parent 44dd0ca4a3
commit a003d261ea
6 changed files with 160 additions and 44 deletions

View File

@@ -92,18 +92,6 @@ function chunkString(str, n, leftAlign) {
return ret;
};
function logObject(msg) {
var args = Array.prototype.slice.call(arguments, 1);
args = args.map(function(arg) {
return JSON.stringify(arg, null, 2);
});
args.unshift(msg);
console.log.apply(console, args);
};
function assert(assertion, msg) {
if (!assertion) {
throw new Error("Assertion failed" + (msg ? ": "+msg : "."));
@@ -157,7 +145,6 @@ exports.hexToArray = hexToArray;
exports.stringToArray = stringToArray;
exports.stringToHex = stringToHex;
exports.chunkString = chunkString;
exports.logObject = logObject;
exports.assert = assert;
exports.arrayUnique = arrayUnique;
exports.toTimestamp = toTimestamp;