|
@@ -29,6 +29,8 @@ const getTimeFormatted = () => {
|
|
|
module.exports = class extends coreClass {
|
|
|
initialize() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
+ this.setStage(1);
|
|
|
+
|
|
|
this.configDirectory = `${__dirname}/../../log`;
|
|
|
|
|
|
if (!config.isDocker && !fs.existsSync(`${this.configDirectory}`))
|
|
@@ -36,12 +38,44 @@ module.exports = class extends coreClass {
|
|
|
|
|
|
let time = getTimeFormatted();
|
|
|
|
|
|
+ this.colors = {
|
|
|
+ Reset: "\x1b[0m",
|
|
|
+ Bright: "\x1b[1m",
|
|
|
+ Dim: "\x1b[2m",
|
|
|
+ Underscore: "\x1b[4m",
|
|
|
+ Blink: "\x1b[5m",
|
|
|
+ Reverse: "\x1b[7m",
|
|
|
+ Hidden: "\x1b[8m",
|
|
|
+
|
|
|
+ FgBlack: "\x1b[30m",
|
|
|
+ FgRed: "\x1b[31m",
|
|
|
+ FgGreen: "\x1b[32m",
|
|
|
+ FgYellow: "\x1b[33m",
|
|
|
+ FgBlue: "\x1b[34m",
|
|
|
+ FgMagenta: "\x1b[35m",
|
|
|
+ FgCyan: "\x1b[36m",
|
|
|
+ FgWhite: "\x1b[37m",
|
|
|
+
|
|
|
+ BgBlack: "\x1b[40m",
|
|
|
+ BgRed: "\x1b[41m",
|
|
|
+ BgGreen: "\x1b[42m",
|
|
|
+ BgYellow: "\x1b[43m",
|
|
|
+ BgBlue: "\x1b[44m",
|
|
|
+ BgMagenta: "\x1b[45m",
|
|
|
+ BgCyan: "\x1b[46m",
|
|
|
+ BgWhite: "\x1b[47m"
|
|
|
+ };
|
|
|
+
|
|
|
fs.appendFile(this.configDirectory + '/all.log', `${time} BACKEND_RESTARTED\n`, ()=>{});
|
|
|
fs.appendFile(this.configDirectory + '/success.log', `${time} BACKEND_RESTARTED\n`, ()=>{});
|
|
|
fs.appendFile(this.configDirectory + '/error.log', `${time} BACKEND_RESTARTED\n`, ()=>{});
|
|
|
fs.appendFile(this.configDirectory + '/info.log', `${time} BACKEND_RESTARTED\n`, ()=>{});
|
|
|
fs.appendFile(this.configDirectory + '/debugStation.log', `${time} BACKEND_RESTARTED\n`, ()=>{});
|
|
|
|
|
|
+ for(let i = 0; i < this.reservedLines; i++) {
|
|
|
+ process.stdout.write("\n");
|
|
|
+ }
|
|
|
+
|
|
|
resolve();
|
|
|
});
|
|
|
}
|
|
@@ -55,7 +89,7 @@ module.exports = class extends coreClass {
|
|
|
this.writeFile('all.log', message);
|
|
|
this.writeFile('success.log', message);
|
|
|
|
|
|
- if (display) console.info('\x1b[32m', message, '\x1b[0m');
|
|
|
+ if (display) this.log(this.colors.FgGreen, message);
|
|
|
}
|
|
|
|
|
|
async error(type, text, display = true) {
|
|
@@ -67,7 +101,7 @@ module.exports = class extends coreClass {
|
|
|
this.writeFile('all.log', message);
|
|
|
this.writeFile('error.log', message);
|
|
|
|
|
|
- if (display) console.warn('\x1b[31m', message, '\x1b[0m');
|
|
|
+ if (display) this.log(this.colors.FgRed, message);
|
|
|
}
|
|
|
|
|
|
async info(type, text, display = true) {
|
|
@@ -78,8 +112,7 @@ module.exports = class extends coreClass {
|
|
|
|
|
|
this.writeFile('all.log', message);
|
|
|
this.writeFile('info.log', message);
|
|
|
-
|
|
|
- if (display) console.info('\x1b[36m', message, '\x1b[0m');
|
|
|
+ if (display) this.log(this.colors.FgCyan, message);
|
|
|
}
|
|
|
|
|
|
async stationIssue(text, display = false) {
|
|
@@ -90,10 +123,19 @@ module.exports = class extends coreClass {
|
|
|
|
|
|
this.writeFile('debugStation.log', message);
|
|
|
|
|
|
- if (display) console.info('\x1b[35m', message, '\x1b[0m');
|
|
|
+ if (display) this.log(this.colors.FgMagenta, message);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ log(color, message) {
|
|
|
+ process.stdout.moveCursor(0, -this.reservedLines);
|
|
|
+ process.stdout.write(`${color}${message}${this.colors.Reset}\n`);
|
|
|
+
|
|
|
+ for(let i = 0; i < this.reservedLines; i++) {
|
|
|
+ process.stdout.write("\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ this.moduleManager.printStatus();
|
|
|
+ }
|
|
|
|
|
|
writeFile(fileName, message) {
|
|
|
fs.appendFile(`${this.configDirectory}/${fileName}`, `${message}\n`, ()=>{});
|