fix: downgrade log-update to version 5.0.1
This commit is contained in:
parent
677fb12ad4
commit
cea9697b6d
5 changed files with 50 additions and 66 deletions
|
@ -54,7 +54,7 @@
|
|||
"commander": "^11.1.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"ioredis": "^5.3.2",
|
||||
"log-update": "^6.0.0",
|
||||
"log-update": "^5.0.1",
|
||||
"pg": "^8.11.3",
|
||||
"semver": "^7.5.4",
|
||||
"systeminformation": "^5.21.15",
|
||||
|
|
|
@ -104,7 +104,7 @@ export class SystemExecutors {
|
|||
|
||||
public cleanLogs = async () => {
|
||||
try {
|
||||
this.logger.flush();
|
||||
await this.logger.flush();
|
||||
this.logger.info('Logs cleaned successfully');
|
||||
|
||||
return { success: true, message: '' };
|
||||
|
@ -170,7 +170,7 @@ export class SystemExecutors {
|
|||
public start = async (sudo = true, killWatchers = true) => {
|
||||
const spinner = new TerminalSpinner('Starting Tipi...');
|
||||
try {
|
||||
this.logger.flush();
|
||||
await this.logger.flush();
|
||||
|
||||
const { isSudo } = getUserIds();
|
||||
|
||||
|
@ -203,8 +203,8 @@ export class SystemExecutors {
|
|||
throw new Error('Tipi needs to run as root to start. Use sudo ./runtipi-cli start');
|
||||
}
|
||||
|
||||
spinner.start();
|
||||
spinner.setMessage('Copying system files...');
|
||||
spinner.start();
|
||||
|
||||
this.logger.info('Copying system files...');
|
||||
await copySystemFiles();
|
||||
|
|
|
@ -2,24 +2,37 @@ import fs from 'fs';
|
|||
import { createLogger } from '@runtipi/shared';
|
||||
import path from 'path';
|
||||
|
||||
function streamLogToHistory(logsFolder: string, logFile: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const appLogReadStream = fs.createReadStream(path.join(logsFolder, logFile), 'utf-8');
|
||||
const appLogHistoryWriteStream = fs.createWriteStream(path.join(logsFolder, `${logFile}.history`), { flags: 'a' });
|
||||
|
||||
appLogReadStream
|
||||
.pipe(appLogHistoryWriteStream)
|
||||
.on('finish', () => {
|
||||
fs.writeFileSync(path.join(logsFolder, logFile), '');
|
||||
resolve(true);
|
||||
})
|
||||
.on('error', (error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class FileLogger {
|
||||
private winstonLogger = createLogger('cli', path.join(process.cwd(), 'logs'));
|
||||
|
||||
private logsFolder = path.join(process.cwd(), 'logs');
|
||||
|
||||
public flush = () => {
|
||||
public flush = async () => {
|
||||
try {
|
||||
if (fs.existsSync(path.join(this.logsFolder, 'app.log'))) {
|
||||
const appLog = fs.readFileSync(path.join(this.logsFolder, 'app.log'), 'utf-8');
|
||||
fs.appendFileSync(path.join(this.logsFolder, 'app.log.history'), appLog);
|
||||
fs.writeFileSync(path.join(this.logsFolder, 'app.log'), '');
|
||||
await streamLogToHistory(this.logsFolder, 'app.log');
|
||||
}
|
||||
|
||||
if (fs.existsSync(path.join(this.logsFolder, 'error.log'))) {
|
||||
const appErrorLog = fs.readFileSync(path.join(this.logsFolder, 'error.log'), 'utf-8');
|
||||
fs.appendFileSync(path.join(this.logsFolder, 'error.log.history'), appErrorLog);
|
||||
fs.writeFileSync(path.join(this.logsFolder, 'error.log'), '');
|
||||
await streamLogToHistory(this.logsFolder, 'error.log');
|
||||
}
|
||||
this.winstonLogger.info('Logs flushed');
|
||||
} catch (error) {
|
||||
this.winstonLogger.error('Error flushing logs', error);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ export const newLogger = (id: string, logsFolder: string) => {
|
|||
);
|
||||
exceptionHandlers = [new transports.File({ filename: path.join(logsFolder, 'error.log') })];
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
tr.push(new transports.Console({ level: 'debug' }));
|
||||
}
|
||||
|
||||
|
|
|
@ -346,8 +346,8 @@ importers:
|
|||
specifier: ^5.3.2
|
||||
version: 5.3.2
|
||||
log-update:
|
||||
specifier: ^6.0.0
|
||||
version: 6.0.0
|
||||
specifier: ^5.0.1
|
||||
version: 5.0.1
|
||||
pg:
|
||||
specifier: ^8.11.3
|
||||
version: 8.11.3
|
||||
|
@ -3697,11 +3697,11 @@ packages:
|
|||
type-fest: 0.21.3
|
||||
dev: true
|
||||
|
||||
/ansi-escapes@6.2.0:
|
||||
resolution: {integrity: sha512-kzRaCqXnpzWs+3z5ABPQiVke+iq0KXkHo8xiWV4RPTi5Yli0l97BEQuhXV1s7+aSU/fu1kUuxgS4MsQ0fRuygw==}
|
||||
engines: {node: '>=14.16'}
|
||||
/ansi-escapes@5.0.0:
|
||||
resolution: {integrity: sha512-5GFMVX8HqE/TB+FuBJGuO5XG0WrsA6ptUqoODaT/n9mmUaZFkqnBueB4leqGBCmrUHnCnC4PCZTCd0E7QQ83bA==}
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
type-fest: 3.13.1
|
||||
type-fest: 1.4.0
|
||||
dev: false
|
||||
|
||||
/ansi-regex@5.0.1:
|
||||
|
@ -4957,10 +4957,6 @@ packages:
|
|||
engines: {node: '>=12'}
|
||||
dev: true
|
||||
|
||||
/emoji-regex@10.3.0:
|
||||
resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==}
|
||||
dev: false
|
||||
|
||||
/emoji-regex@8.0.0:
|
||||
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||
|
||||
|
@ -5937,11 +5933,6 @@ packages:
|
|||
engines: {node: 6.* || 8.* || >= 10.*}
|
||||
dev: true
|
||||
|
||||
/get-east-asian-width@1.2.0:
|
||||
resolution: {integrity: sha512-2nk+7SIVb14QrgXFHcm84tD4bKQz0RxPuMT8Ag5KPOq7J5fEmAg0UbXdTOSHqNuHSU28k55qnceesxXRZGzKWA==}
|
||||
engines: {node: '>=18'}
|
||||
dev: false
|
||||
|
||||
/get-func-name@2.0.2:
|
||||
resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==}
|
||||
dev: true
|
||||
|
@ -6587,11 +6578,9 @@ packages:
|
|||
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
/is-fullwidth-code-point@5.0.0:
|
||||
resolution: {integrity: sha512-OVa3u9kkBbw7b8Xw5F9P+D/T9X+Z4+JruYVNapTjPYZYUznQ5YfWeFkOj606XYYW8yugTfC8Pj0hYqvi4ryAhA==}
|
||||
engines: {node: '>=18'}
|
||||
dependencies:
|
||||
get-east-asian-width: 1.2.0
|
||||
/is-fullwidth-code-point@4.0.0:
|
||||
resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==}
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/is-generator-fn@2.1.0:
|
||||
|
@ -7559,15 +7548,15 @@ packages:
|
|||
is-unicode-supported: 0.1.0
|
||||
dev: true
|
||||
|
||||
/log-update@6.0.0:
|
||||
resolution: {integrity: sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw==}
|
||||
engines: {node: '>=18'}
|
||||
/log-update@5.0.1:
|
||||
resolution: {integrity: sha512-5UtUDQ/6edw4ofyljDNcOVJQ4c7OjDro4h3y8e1GQL5iYElYclVHJ3zeWchylvMaKnDbDilC8irOVyexnA/Slw==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dependencies:
|
||||
ansi-escapes: 6.2.0
|
||||
ansi-escapes: 5.0.0
|
||||
cli-cursor: 4.0.0
|
||||
slice-ansi: 7.1.0
|
||||
slice-ansi: 5.0.0
|
||||
strip-ansi: 7.1.0
|
||||
wrap-ansi: 9.0.0
|
||||
wrap-ansi: 8.1.0
|
||||
dev: false
|
||||
|
||||
/logform@2.5.1:
|
||||
|
@ -9851,12 +9840,12 @@ packages:
|
|||
engines: {node: '>=12'}
|
||||
dev: true
|
||||
|
||||
/slice-ansi@7.1.0:
|
||||
resolution: {integrity: sha512-bSiSngZ/jWeX93BqeIAbImyTbEihizcwNjFoRUIY/T1wWQsfsm2Vw1agPKylXvQTU7iASGdHhyqRlqQzfz+Htg==}
|
||||
engines: {node: '>=18'}
|
||||
/slice-ansi@5.0.0:
|
||||
resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==}
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
ansi-styles: 6.2.1
|
||||
is-fullwidth-code-point: 5.0.0
|
||||
is-fullwidth-code-point: 4.0.0
|
||||
dev: false
|
||||
|
||||
/source-map-js@1.0.2:
|
||||
|
@ -9999,15 +9988,6 @@ packages:
|
|||
emoji-regex: 9.2.2
|
||||
strip-ansi: 7.1.0
|
||||
|
||||
/string-width@7.0.0:
|
||||
resolution: {integrity: sha512-GPQHj7row82Hjo9hKZieKcHIhaAIKOJvFSIZXuCU9OASVZrMNUaZuz++SPVrBjnLsnk4k+z9f2EIypgxf2vNFw==}
|
||||
engines: {node: '>=18'}
|
||||
dependencies:
|
||||
emoji-regex: 10.3.0
|
||||
get-east-asian-width: 1.2.0
|
||||
strip-ansi: 7.1.0
|
||||
dev: false
|
||||
|
||||
/string.fromcodepoint@0.2.1:
|
||||
resolution: {integrity: sha512-n69H31OnxSGSZyZbgBlvYIXlrMhJQ0dQAX1js1QDhpaUH6zmU3QYlj07bCwCNlPOu3oRXIubGPl2gDGnHsiCqg==}
|
||||
dev: true
|
||||
|
@ -10536,15 +10516,15 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/type-fest@1.4.0:
|
||||
resolution: {integrity: sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==}
|
||||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/type-fest@2.19.0:
|
||||
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
|
||||
engines: {node: '>=12.20'}
|
||||
|
||||
/type-fest@3.13.1:
|
||||
resolution: {integrity: sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==}
|
||||
engines: {node: '>=14.16'}
|
||||
dev: false
|
||||
|
||||
/typed-array-buffer@1.0.0:
|
||||
resolution: {integrity: sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
@ -11206,15 +11186,6 @@ packages:
|
|||
string-width: 5.1.2
|
||||
strip-ansi: 7.1.0
|
||||
|
||||
/wrap-ansi@9.0.0:
|
||||
resolution: {integrity: sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==}
|
||||
engines: {node: '>=18'}
|
||||
dependencies:
|
||||
ansi-styles: 6.2.1
|
||||
string-width: 7.0.0
|
||||
strip-ansi: 7.1.0
|
||||
dev: false
|
||||
|
||||
/wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
|
||||
|
|
Loading…
Reference in a new issue