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,
} 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")

View File

@ -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,