]>
git.r.bdr.sh - rbdr/cologne/blob - lib/cologne/logger/console.js
3a73e420b569690224ec75a2cdb0ea96b504ac05
3 let LogUtilities
= require('../log_utilities');
6 * Logger for the javascript console.
8 * @memberof Cologne.Logger
9 * @implements Cologne.ILogger
12 let ConsoleLogger
= class ConsoleLogger
{
13 constructor (config
) {
16 * The console it will write to, can be any object that looks
17 * and acts like a console, including other cologne objects.
21 * @memberof Cologne.Logger.Console
23 * @default global.console
25 this.console
= console
;
28 * The formatter it will use to output the log. If not present it
29 * will output raw JSON
33 * @memberof Cologne.Logger.Console
34 * @type Cologne.IFormatter
37 this.formatter
= null;
39 Object
.assign(this, config
|| {});
44 * Main entry point, for each incoming argument it will attempt to
45 * format and send to the console.
49 * @memberof Cologne.Logger.Console
53 let logObject
, messages
, severity
;
57 for (logObject
of arguments
) {
58 messages
.push(this._format(logObject
));
61 severity
= logObject
._level
;
70 this.console
.error
.apply(this.console
, messages
);
73 this.console
.warn
.apply(this.console
, messages
);
77 this.console
.info
.apply(this.console
, messages
);
81 this.console
.log
.apply(this.console
, messages
);
88 return this.formatter
.format(logObject
);
91 return LogUtilities
.stringify(logObject
);
95 module
.exports
= ConsoleLogger
;