1 | const chalk = require('chalk');
|
2 |
|
3 | /**
|
4 | * @param {String} namespace log prefix.
|
5 | *
|
6 | * @returns {Object} Logger with `log` and `error` function.
|
7 | */
|
8 | module.exports = namespace => {
|
9 | return {
|
10 | log(...args) {
|
11 | console.log(`${namespace ? `${chalk.magenta(`[${namespace}]:`)} ` : ''}${args.join()}`);
|
12 | },
|
13 | error(...args) {
|
14 | console.error(`${namespace ? `${chalk.magenta(`[${namespace}]:`)} ` : ''}${chalk.red(args.join())}`);
|
15 | },
|
16 | };
|
17 | };
|