Fix logger not creating log file

This commit is contained in:
Silvano Cerza 2025-02-28 17:51:55 +01:00
parent 28abd1c1cc
commit cd0f54a117
2 changed files with 9 additions and 0 deletions

View file

@ -12,6 +12,14 @@ export default class Logger {
this.logFile = normalizePath(`${vault.configDir}/${LOG_FILE_NAME}`);
}
async init() {
// Create the log file in case it doesn't exist
if (await this.vault.adapter.exists(this.logFile)) {
return;
}
this.vault.adapter.write(this.logFile, "");
}
private async write(
level: string,
message: string,

View file

@ -90,6 +90,7 @@ export default class GitHubSyncPlugin extends Plugin {
this.getConflictsView()?.setConflictFiles(this.conflicts);
});
this.logger = new Logger(this.app.vault, this.settings.enableLogging);
this.logger.init();
this.addSettingTab(new GitHubSyncSettingsTab(this.app, this));