mirror of
https://github.com/silvanocerza/github-gitless-sync.git
synced 2026-07-22 05:41:36 +00:00
Add settings to disable logging
This commit is contained in:
parent
2c4ed3e671
commit
ac1e53f79c
4 changed files with 29 additions and 5 deletions
|
|
@ -3,12 +3,13 @@ import { Vault, normalizePath } from "obsidian";
|
|||
const LOG_FILE_NAME = "github-sync.log" as const;
|
||||
|
||||
export default class Logger {
|
||||
private enabled: boolean;
|
||||
private logFile: string;
|
||||
|
||||
constructor(private vault: Vault) {
|
||||
constructor(
|
||||
private vault: Vault,
|
||||
private enabled: boolean,
|
||||
) {
|
||||
this.logFile = normalizePath(`${vault.configDir}/${LOG_FILE_NAME}`);
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
private async write(
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ export default class GitHubSyncPlugin extends Plugin {
|
|||
}
|
||||
|
||||
async onload() {
|
||||
this.logger = new Logger(this.app.vault);
|
||||
|
||||
await this.loadSettings();
|
||||
|
||||
this.logger = new Logger(this.app.vault, this.settings.enableLogging);
|
||||
|
||||
this.addSettingTab(new GitHubSyncSettingsTab(this.app, this));
|
||||
|
||||
this.syncManager = new SyncManager(
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export interface GitHubSyncSettings {
|
|||
conflictHandling: "ignore" | "ask" | "overwrite";
|
||||
showStatusBarItem: boolean;
|
||||
showSyncRibbonButton: boolean;
|
||||
enableLogging: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_SETTINGS: GitHubSyncSettings = {
|
||||
|
|
@ -26,4 +27,5 @@ export const DEFAULT_SETTINGS: GitHubSyncSettings = {
|
|||
conflictHandling: "ask",
|
||||
showStatusBarItem: true,
|
||||
showSyncRibbonButton: true,
|
||||
enableLogging: true,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -214,5 +214,26 @@ export default class GitHubSyncSettingsTab extends PluginSettingTab {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
containerEl.createEl("h2", { text: "Extra" });
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Enable logging")
|
||||
.setDesc(
|
||||
"If enabled logs from this plugin will be saved in a file in your config directory.",
|
||||
)
|
||||
.addToggle((toggle) => {
|
||||
toggle
|
||||
.setValue(this.plugin.settings.enableLogging)
|
||||
.onChange((value) => {
|
||||
this.plugin.settings.enableLogging = value;
|
||||
if (value) {
|
||||
this.plugin.logger.enable();
|
||||
} else {
|
||||
this.plugin.logger.disable();
|
||||
}
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue