]>
git.r.bdr.sh - rbdr/cologne/blob - lib/loggers/console.js
5e5ded1241d494ac0bcfcb70cf23cdff34ead9f0
3 const Utilities
= require('../utilities');
6 * Logger for the javascript console.
12 module
.exports
= class ConsoleLogger
{
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 Loggers.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 Loggers.Console
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 Loggers.Console
54 const formattedLogs
= logs
.map((log
) => ({ log: this._format(log
), level: log
._level
}));
56 for (const { log
, level
} of formattedLogs
) {
57 this._log(log
, level
);
62 // Routes an individual log to the appropriatet console
71 this.console
.error(log
);
74 this.console
.warn(log
);
78 this.console
.info(log
);
82 this.console
.log(log
);
90 return this.formatter
.format(logObject
);
93 return Utilities
.stringify(logObject
);