mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 02:19:08 +00:00
chore: remove semi
This commit is contained in:
parent
4b75eaa0ab
commit
8fcc0dcbf9
64 changed files with 1073 additions and 1073 deletions
|
@ -1,4 +1,4 @@
|
|||
const chalk = require('chalk');
|
||||
const chalk = require('chalk')
|
||||
// const { debug } = require('yargs').argv
|
||||
// process.env.DEBUG = process.env.DEBUG || debug
|
||||
// logger template//
|
||||
|
@ -6,54 +6,54 @@ const chalk = require('chalk');
|
|||
|
||||
class Logger {
|
||||
constructor(name, debugOverride = false) {
|
||||
this.name = name;
|
||||
this.name = name
|
||||
this.debugOn =
|
||||
process.env.DEBUG === 'true' || process.env.DEBUG === '*' || debugOverride;
|
||||
process.env.DEBUG === 'true' || process.env.DEBUG === '*' || debugOverride
|
||||
}
|
||||
|
||||
fatal(text, ...data) {
|
||||
this.error(text, data);
|
||||
this.error(text, data)
|
||||
|
||||
if (typeof data[data.length - 1] === 'number') {
|
||||
process.exit(data[data.length - 1]);
|
||||
process.exit(data[data.length - 1])
|
||||
} else {
|
||||
process.exit(1);
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
throw text;
|
||||
throw text
|
||||
}
|
||||
|
||||
error(text, ...data) {
|
||||
console.error(chalk.red.bold(`ERR ${this.name}:`) + `\n ${text}`, data);
|
||||
console.error(chalk.red.bold(`ERR ${this.name}:`) + `\n ${text}`, data)
|
||||
}
|
||||
|
||||
warn(text, ...data) {
|
||||
console.warn(chalk.yellow.bold(`WARN ${this.name}:`) + `\n ${text}`, data);
|
||||
console.warn(chalk.yellow.bold(`WARN ${this.name}:`) + `\n ${text}`, data)
|
||||
}
|
||||
|
||||
notice(text, ...data) {
|
||||
console.log(chalk.cyan.bold(`NOTICE ${this.name}:`) + `\n ${text}`, data);
|
||||
console.log(chalk.cyan.bold(`NOTICE ${this.name}:`) + `\n ${text}`, data)
|
||||
}
|
||||
|
||||
info(text, ...data) {
|
||||
console.info(chalk.blue.bold(`INFO ${this.name}:`) + `\n ${text}`, data);
|
||||
console.info(chalk.blue.bold(`INFO ${this.name}:`) + `\n ${text}`, data)
|
||||
}
|
||||
|
||||
request(text, ...data) {
|
||||
console.info(chalk.green.bold(`HTTP ${this.name}:`) + `\n ${text}`);
|
||||
console.info(chalk.green.bold(`HTTP ${this.name}:`) + `\n ${text}`)
|
||||
}
|
||||
|
||||
debug(text, ...data) {
|
||||
if (this.debugOn) {
|
||||
console.log(chalk.gray.bold(`DEBUG ${this.name}:`) + `\n ${text}`, data);
|
||||
console.log(chalk.gray.bold(`DEBUG ${this.name}:`) + `\n ${text}`, data)
|
||||
}
|
||||
}
|
||||
|
||||
sql(logger, ...data) {
|
||||
if (logger.debugOn) {
|
||||
console.log(chalk.bold('DEBUG SQL:\n '), data);
|
||||
console.log(chalk.bold('DEBUG SQL:\n '), data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Logger;
|
||||
module.exports = Logger
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue