1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

All: Resolves #5521: Rotating log files (#8376)

Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
Hubert
2023-07-14 10:24:25 -03:00
committed by GitHub
parent f4019dbcd3
commit 33ba934937
3 changed files with 107 additions and 0 deletions

View File

@@ -59,6 +59,8 @@ import Resource from './models/Resource';
import { ProfileConfig } from './services/profileConfig/types';
import initProfile from './services/profileConfig/initProfile';
import RotatingLogs from './RotatingLogs';
const appLogger: LoggerWrapper = Logger.create('App');
// const ntpClient = require('./vendor/ntp-client');
@@ -85,6 +87,8 @@ export default class BaseApplication {
protected store_: Store<any> = null;
private rotatingLogs: RotatingLogs;
public constructor() {
this.eventEmitter_ = new EventEmitter();
this.decryptionWorker_resourceMetadataButNotBlobDecrypted = this.decryptionWorker_resourceMetadataButNotBlobDecrypted.bind(this);
@@ -927,6 +931,18 @@ export default class BaseApplication {
await MigrationService.instance().run();
this.rotatingLogs = new RotatingLogs(profileDir);
const processLogs = async () => {
try {
await this.rotatingLogs.cleanActiveLogFile();
await this.rotatingLogs.deleteNonActiveLogFiles();
} catch (error) {
appLogger.error(error);
}
};
shim.setTimeout(() => { void processLogs(); }, 60000);
shim.setInterval(() => { void processLogs(); }, 24 * 60 * 60 * 1000);
return argv;
}
}