diff --git a/src/settings.ts b/src/settings.ts index b4d347d..75088da 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -20,8 +20,8 @@ import { getAuthUrlAndVerifier as getAuthUrlAndVerifierOnedrive, } from "./remoteForOnedrive"; -import * as origLog from 'loglevel'; -const log = origLog.getLogger('rs-default'); +import * as origLog from "loglevel"; +const log = origLog.getLogger("rs-default"); class PasswordModal extends Modal { plugin: RemotelySavePlugin; @@ -897,6 +897,25 @@ export class RemotelySaveSettingTab extends PluginSettingTab { const debugDiv = containerEl.createEl("div"); debugDiv.createEl("h2", { text: "Debug" }); + + const setConsoleLogLevelDiv = debugDiv.createDiv("div"); + new Setting(setConsoleLogLevelDiv) + .setName("alter console log level") + .setDesc( + 'By default the log level is "info". You can change to "debug" to get verbose infomation in console.' + ) + .addDropdown(async (dropdown) => { + dropdown.addOption("info", "info"); + dropdown.addOption("debug", "debug"); + dropdown + .setValue(this.plugin.settings.currLogLevel) + .onChange(async (val: string) => { + this.plugin.settings.currLogLevel = val; + log.setLevel(val as any); + await this.plugin.saveSettings(); + log.info(`the log level is changed to ${val}`); + }); + }); const syncPlanDiv = debugDiv.createEl("div"); new Setting(syncPlanDiv) .setName("export sync plans") diff --git a/src/sync.ts b/src/sync.ts index df9edae..64e9e40 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -16,6 +16,9 @@ import { import { isHiddenPath, isVaildText, mkdirpInVault } from "./misc"; import { RemoteClient } from "./remote"; +import * as origLog from "loglevel"; +const log = origLog.getLogger("rs-default"); + export type SyncStatusType = | "idle" | "preparing" @@ -573,9 +576,10 @@ export const doActualSync = async ( )) { const k2 = k as string; const v2 = v as FileOrFolderMixedState; + log.debug(`start syncing "${k2}" with plan ${JSON.stringify(v2)}`); await dispatchOperationToActual( - k as string, - v as FileOrFolderMixedState, + k2, + v2, client, db, vault,