]>
git.r.bdr.sh - rbdr/cologne/blob - lib/loggers/console.js
3 const Utilities
= require('../utilities');
6 * Logger for the javascript console.
11 module
.exports
= class ConsoleLogger
{
15 * The console it will write to, can be any object that looks
16 * and acts like a console, including other cologne objects.
20 * @memberof Loggers.Console
22 * @default global.console
24 this.console
= console
;
27 * The formatter it will use to output the log. If not present it
28 * will output raw JSON
32 * @memberof Loggers.Console
36 this.formatter
= null;
38 Object
.assign(this, config
);
43 * Main entry point, for each incoming argument it will attempt to
44 * format and send to the console.
48 * @memberof Loggers.Console
53 const formattedLogs
= logs
.map((log
) => ({ log: this._format(log
), level: log
._level
}));
55 for (const { log
, level
} of formattedLogs
) {
56 this._log(log
, level
);
61 // Routes an individual log to the appropriatet console
70 this.console
.error(log
);
73 this.console
.warn(log
);
77 this.console
.info(log
);
81 this.console
.log(log
);
89 return this.formatter
.format(logObject
);
92 return Utilities
.stringify(logObject
);