forked from Hri7566/mpp-server-dev2
29 lines
561 B
JavaScript
29 lines
561 B
JavaScript
const chalk = require('chalk');
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Logger;
|
|
|