log debug every sync file

This commit is contained in:
fyears 2022-01-05 00:24:21 +08:00
parent 8671ba4660
commit 313eff6a14
2 changed files with 27 additions and 4 deletions

View File

@ -20,8 +20,8 @@ import {
getAuthUrlAndVerifier as getAuthUrlAndVerifierOnedrive, getAuthUrlAndVerifier as getAuthUrlAndVerifierOnedrive,
} from "./remoteForOnedrive"; } from "./remoteForOnedrive";
import * as origLog from 'loglevel'; import * as origLog from "loglevel";
const log = origLog.getLogger('rs-default'); const log = origLog.getLogger("rs-default");
class PasswordModal extends Modal { class PasswordModal extends Modal {
plugin: RemotelySavePlugin; plugin: RemotelySavePlugin;
@ -897,6 +897,25 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
const debugDiv = containerEl.createEl("div"); const debugDiv = containerEl.createEl("div");
debugDiv.createEl("h2", { text: "Debug" }); 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"); const syncPlanDiv = debugDiv.createEl("div");
new Setting(syncPlanDiv) new Setting(syncPlanDiv)
.setName("export sync plans") .setName("export sync plans")

View File

@ -16,6 +16,9 @@ import {
import { isHiddenPath, isVaildText, mkdirpInVault } from "./misc"; import { isHiddenPath, isVaildText, mkdirpInVault } from "./misc";
import { RemoteClient } from "./remote"; import { RemoteClient } from "./remote";
import * as origLog from "loglevel";
const log = origLog.getLogger("rs-default");
export type SyncStatusType = export type SyncStatusType =
| "idle" | "idle"
| "preparing" | "preparing"
@ -573,9 +576,10 @@ export const doActualSync = async (
)) { )) {
const k2 = k as string; const k2 = k as string;
const v2 = v as FileOrFolderMixedState; const v2 = v as FileOrFolderMixedState;
log.debug(`start syncing "${k2}" with plan ${JSON.stringify(v2)}`);
await dispatchOperationToActual( await dispatchOperationToActual(
k as string, k2,
v as FileOrFolderMixedState, v2,
client, client,
db, db,
vault, vault,