mpp-server-dev2/src/Logger.js

29 lines
561 B
JavaScript
Raw Normal View History

2021-05-09 22:34:22 +02:00
const chalk = require('chalk');
2022-05-24 20:29:29 +02:00
class Logger {
2021-05-09 22:34:22 +02:00
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);
}
}
2022-05-24 20:29:29 +02:00
}
module.exports = Logger;