X-Git-Url: https://git.r.bdr.sh/rbdr/cologne/blobdiff_plain/bdedb5e54032363de8afa322fadae0e2cb2132d0..5c03d3b44c5daeb34180c6922fcf3307f1217cbc:/lib/loggers/console.js diff --git a/lib/loggers/console.js b/lib/loggers/console.js index 3dc4b1d..c8e3036 100644 --- a/lib/loggers/console.js +++ b/lib/loggers/console.js @@ -16,7 +16,7 @@ Cobalt.Logger.JsConsole = Class(Cobalt.Logger, 'JsConsole')({ prototype : { - console : console, + console : null, formatterOpts : {}, init : function (config) { @@ -28,30 +28,47 @@ logger[property] = config[property]; } } + + if (!logger.console) { + logger.console = console; + } }, - log : function (logObject) { - var message; + log : function () { + var i, message = [], severity; - message = this.format(logObject); + for (i = 0; i < arguments.length; i++) { + // We're not formatting objects for now. - switch (logObject._level){ + if (!arguments[i].__skipConsole && !arguments[i].message.__skipConsole) { + if (typeof arguments[i].message === 'object') { + message.push(arguments[i].message); + } else { + message.push(this.format(arguments[i])); + } + if (!severity) { + severity = arguments[i]._level + } + } + } + + switch (severity){ case 0: case 1: case 2: case 3: - this.console.error(message); + this.console.error.apply(this.console, message); break; case 4: - this.console.warn(message); + this.console.warn.apply(this.console, message); break; case 5: case 6: - this.console.info(message); + this.console.info.apply(this.console, message); break; case 7: default: - this.console.log(message); + this.console.log.apply(this.console, message); break; } }, @@ -63,11 +80,15 @@ return this.formatter.format(logObject, this.formatterOpts); } - return logObject; + return logObject.message; } } }); + if (Cobalt.Logger.JsConsole.__objectSpy) { + Cobalt.Logger.JsConsole.__objectSpy.destroy(); + } + if (typeof require === 'function') { global.JsConsole = Cobalt.Logger.JsConsole; } else {