mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-03 16:02:29 +00:00
Refactor: Constantising log-mark
This commit is contained in:
+1
-1
Submodule src/lib updated: b19f087599...1c176da469
@@ -15,6 +15,7 @@ import { ReplicateResultProcessor } from "./ReplicateResultProcessor";
|
|||||||
import { UnresolvedErrorManager } from "@lib/services/base/UnresolvedErrorManager";
|
import { UnresolvedErrorManager } from "@lib/services/base/UnresolvedErrorManager";
|
||||||
import { clearHandlers } from "@lib/replication/SyncParamsHandler";
|
import { clearHandlers } from "@lib/replication/SyncParamsHandler";
|
||||||
import type { NecessaryServices } from "@/serviceFeatures/types";
|
import type { NecessaryServices } from "@/serviceFeatures/types";
|
||||||
|
import { MARK_LOG_NETWORK_ERROR } from "@lib/services/lib/logUtils";
|
||||||
|
|
||||||
function isOnlineAndCanReplicate(
|
function isOnlineAndCanReplicate(
|
||||||
errorManager: UnresolvedErrorManager,
|
errorManager: UnresolvedErrorManager,
|
||||||
@@ -46,7 +47,7 @@ async function canReplicateWithPBKDF2(
|
|||||||
errorManager.clearError(errorMessage);
|
errorManager.clearError(errorMessage);
|
||||||
// Showing message is false: that because be shown here. (And it is a fatal error, no way to hide it).
|
// Showing message is false: that because be shown here. (And it is a fatal error, no way to hide it).
|
||||||
// tagged as network error at beginning for error filtering with NetworkWarningStyles
|
// tagged as network error at beginning for error filtering with NetworkWarningStyles
|
||||||
const ensureMessage = "\u{200b}Failed to initialise the encryption key, preventing replication.";
|
const ensureMessage = `${MARK_LOG_NETWORK_ERROR}Failed to initialise the encryption key, preventing replication.`;
|
||||||
const ensureResult = await replicator.ensurePBKDF2Salt(currentSettings, showMessage, true);
|
const ensureResult = await replicator.ensurePBKDF2Salt(currentSettings, showMessage, true);
|
||||||
if (!ensureResult) {
|
if (!ensureResult) {
|
||||||
errorManager.showError(ensureMessage, showMessage ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO);
|
errorManager.showError(ensureMessage, showMessage ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { PouchDB } from "../../lib/src/pouchdb/pouchdb-browser.ts";
|
|||||||
import { AuthorizationHeaderGenerator } from "../../lib/src/replication/httplib.ts";
|
import { AuthorizationHeaderGenerator } from "../../lib/src/replication/httplib.ts";
|
||||||
import type { LiveSyncCore } from "../../main.ts";
|
import type { LiveSyncCore } from "../../main.ts";
|
||||||
import { EVENT_ON_UNRESOLVED_ERROR, eventHub } from "../../common/events.ts";
|
import { EVENT_ON_UNRESOLVED_ERROR, eventHub } from "../../common/events.ts";
|
||||||
|
import { MARK_LOG_NETWORK_ERROR } from "@lib/services/lib/logUtils.ts";
|
||||||
|
|
||||||
setNoticeClass(Notice);
|
setNoticeClass(Notice);
|
||||||
|
|
||||||
@@ -236,7 +237,7 @@ export class ModuleObsidianAPI extends AbstractObsidianModule {
|
|||||||
} catch (ex: any) {
|
} catch (ex: any) {
|
||||||
this._log(`HTTP:${method}${size} to:${localURL} -> failed`, LOG_LEVEL_VERBOSE);
|
this._log(`HTTP:${method}${size} to:${localURL} -> failed`, LOG_LEVEL_VERBOSE);
|
||||||
const msg = ex instanceof Error ? `${ex?.name}:${ex?.message}` : ex?.toString();
|
const msg = ex instanceof Error ? `${ex?.name}:${ex?.message}` : ex?.toString();
|
||||||
this.showError(`\u{200b}Network Error: Failed to fetch: ${msg}`); // Do not show notice, due to throwing below
|
this.showError(`${MARK_LOG_NETWORK_ERROR}Network Error: Failed to fetch: ${msg}`); // Do not show notice, due to throwing below
|
||||||
this._log(ex, LOG_LEVEL_VERBOSE);
|
this._log(ex, LOG_LEVEL_VERBOSE);
|
||||||
// limit only in bulk_docs.
|
// limit only in bulk_docs.
|
||||||
if (url.toString().indexOf("_bulk_docs") !== -1) {
|
if (url.toString().indexOf("_bulk_docs") !== -1) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import {
|
|||||||
isValidFilenameInDarwin,
|
isValidFilenameInDarwin,
|
||||||
isValidFilenameInWidows,
|
isValidFilenameInWidows,
|
||||||
} from "@lib/string_and_binary/path.ts";
|
} from "@lib/string_and_binary/path.ts";
|
||||||
import { MARK_LOG_SEPARATOR } from "@lib/services/lib/logUtils.ts";
|
import { MARK_LOG_NETWORK_ERROR, MARK_LOG_SEPARATOR } from "@lib/services/lib/logUtils.ts";
|
||||||
import { NetworkWarningStyles } from "@lib/common/models/setting.const.ts";
|
import { NetworkWarningStyles } from "@lib/common/models/setting.const.ts";
|
||||||
|
|
||||||
// This module cannot be a core module because it depends on the Obsidian UI.
|
// This module cannot be a core module because it depends on the Obsidian UI.
|
||||||
@@ -284,8 +284,8 @@ export class ModuleLog extends AbstractObsidianModule {
|
|||||||
if (fileStatus && !this.settings.hideFileWarningNotice) messageLines.push(fileStatus);
|
if (fileStatus && !this.settings.hideFileWarningNotice) messageLines.push(fileStatus);
|
||||||
const messages = (await this.services.appLifecycle.getUnresolvedMessages()).flat().filter((e) => e);
|
const messages = (await this.services.appLifecycle.getUnresolvedMessages()).flat().filter((e) => e);
|
||||||
const stringMessages = messages.filter((m): m is string => typeof m === "string"); // for 'startsWith'
|
const stringMessages = messages.filter((m): m is string => typeof m === "string"); // for 'startsWith'
|
||||||
const networkMessages = stringMessages.filter((m) => m.startsWith("\u{200b}"));
|
const networkMessages = stringMessages.filter((m) => m.startsWith(MARK_LOG_NETWORK_ERROR));
|
||||||
const otherMessages = stringMessages.filter((m) => !m.startsWith("\u{200b}"));
|
const otherMessages = stringMessages.filter((m) => !m.startsWith(MARK_LOG_NETWORK_ERROR));
|
||||||
|
|
||||||
messageLines.push(...otherMessages);
|
messageLines.push(...otherMessages);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user