- var Cobalt = {};
- Module(Cobalt, 'Logger')({});
-
- Cobalt.Logger.JsConsole = Class(Cobalt.Logger, 'JsConsole')({
- prototype : {
- console : null,
- formatterOpts : {},
-
- init : function (config) {
- var logger = this,
- property;
-
- if (config) {
- for (property in config) {
- logger[property] = config[property];
- }
- }
-
- if (!logger.console) {
- logger.console = console;
- }
- },
-
- log : function () {
- var i, messageArray = [], message, severity;
-
- for (i = 0; i < arguments.length; i++) {
- messageArray.push(this.format(arguments[i]));
- if (!severity) {
- severity = arguments[i]._level
- }
- }
-
- message = messageArray.join(' ');
-
- switch (severity){
- case 0:
- case 1:
- case 2:
- case 3:
- this.console.error(message);
- break;
- case 4:
- this.console.warn(message);
- break;
- case 5:
- case 6:
- this.console.info(message);
- break;
- case 7:
- default:
- this.console.log(message);
- break;
- }
- },
-
- format : function (logObject) {
- // Usually what you want to do here is format. Preferably using
- // someone inside Cobalt.Formatter
- if (this.formatter) {
- return this.formatter.format(logObject, this.formatterOpts);
- }
-
- return logObject;
- }
+
+ /**
+ * Main entry point, for each incoming argument it will attempt to
+ * format and send to the console.
+ *
+ * @function log
+ * @instance
+ * @memberof Loggers.Console
+ * @return {undefined}
+ */
+ log(...logs) {
+
+ const formattedLogs = logs.map((log) => ({ log: this._format(log), level: log._level }));
+
+ for (const { log, level } of formattedLogs) {
+ this._log(log, level );