mpp-server-dev2/src/Logger.js

25 lines
550 B
JavaScript
Raw Normal View History

2021-05-09 22:34:22 +02:00
const chalk = require('chalk');
module.exports = class Logger {
constructor (context) {
this.context = context;
}
log(args) {
console.log(chalk.green(`[${this.context}]`), args);
}
warn(args) {
console.warn(chalk.yellow(`[WARN] [${this.context}]`), args);
}
error(args) {
console.error(chalk.red(`[ERR] [${this.context}]`), args);
}
debug(args) {
if (process.env.DEBUG_ENABLED) {
console.log(chalk.blue(`[DEBUG] [${this.context}]`), args);
}
}
}