mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 08:08:34 +08:00
refactor: remove redundant debug logs from upload commands and base class
This commit is contained in:
@@ -90,12 +90,6 @@ export class Upload2Notion extends UploadBase {
|
||||
|
||||
async sync(request: SyncRequest): Promise<NotionPageResponse> {
|
||||
const startedAt = Date.now();
|
||||
this.debugLog("Upload2Notion", "Sync invoked", {
|
||||
dataset: request.dataset,
|
||||
filePath: request.nowFile.path,
|
||||
databaseId: this.dbDetails.databaseID,
|
||||
abName: this.dbDetails.abName,
|
||||
});
|
||||
|
||||
let response: NotionPageResponse;
|
||||
|
||||
@@ -113,19 +107,7 @@ export class Upload2Notion extends UploadBase {
|
||||
throw new Error(`Unsupported dataset type: ${(request as any).dataset}`);
|
||||
}
|
||||
|
||||
console.log(`[Upload2Notion] Notion response status`, response.response?.status);
|
||||
this.debugLog("Upload2Notion", "Sync completed", {
|
||||
status: response.response?.status ?? null,
|
||||
durationMs: Date.now() - startedAt,
|
||||
pageId: response.data?.id ?? null,
|
||||
pageUrl: response.data?.url ?? null,
|
||||
});
|
||||
|
||||
if (response.response && response.response.status === 200) {
|
||||
console.log(`[Upload2Notion] Sync success`, {
|
||||
notionPageId: response.data?.id,
|
||||
notionPageUrl: response.data?.url,
|
||||
});
|
||||
await updateYamlInfo(
|
||||
request.markdown,
|
||||
request.nowFile,
|
||||
@@ -247,11 +229,6 @@ export class Upload2Notion extends UploadBase {
|
||||
const {abName} = this.dbDetails;
|
||||
const notionIDKey = `NotionID-${abName}`;
|
||||
const notionId = frontMatter[notionIDKey];
|
||||
this.debugLog("Upload2Notion", "Resolved Notion ID from frontmatter", {
|
||||
filePath: nowFile.path,
|
||||
notionId: notionId ? String(notionId) : null,
|
||||
frontMatterKeys: Object.keys(frontMatter),
|
||||
});
|
||||
return notionId ? String(notionId) : undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,6 @@ export abstract class UploadBase {
|
||||
|
||||
async deletePage(notionID: string) {
|
||||
const {notionAPI} = this.dbDetails;
|
||||
this.debugLog("UploadBase", "Deleting Notion page", {
|
||||
notionId: notionID,
|
||||
apiTokenPreview: this.maskValue(notionAPI),
|
||||
});
|
||||
return requestUrl({
|
||||
url: `https://api.notion.com/v1/blocks/${notionID}`,
|
||||
method: "DELETE",
|
||||
@@ -47,7 +43,6 @@ export abstract class UploadBase {
|
||||
this.stripCodeAnnotations(childArr);
|
||||
|
||||
const childArrLength = childArr.length;
|
||||
console.log(`Page includes ${childArrLength} blocks`);
|
||||
|
||||
if (childArrLength <= 100) {
|
||||
this.debugLog("UploadBase", "Blocks fit into a single request", {
|
||||
@@ -108,9 +103,6 @@ export abstract class UploadBase {
|
||||
return cover;
|
||||
}
|
||||
const databaseCover = await this.fetchDatabaseCover();
|
||||
this.debugLog("UploadBase", "Cover fetched from database", {
|
||||
databaseCover: databaseCover ?? null,
|
||||
});
|
||||
return databaseCover ?? undefined;
|
||||
}
|
||||
|
||||
@@ -144,8 +136,6 @@ export abstract class UploadBase {
|
||||
new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000);
|
||||
console.log(`Error message: \n ${data.message}`);
|
||||
} else {
|
||||
console.log(`Page created: ${data.url}`);
|
||||
console.log(`Page ID: ${data.id}`);
|
||||
if (extraChunks.length > 0) {
|
||||
await this.appendExtraBlocks(data.id, extraChunks);
|
||||
}
|
||||
@@ -206,10 +196,6 @@ export abstract class UploadBase {
|
||||
|
||||
private async fetchDatabaseCover(): Promise<string | null> {
|
||||
const {notionAPI, databaseID} = this.dbDetails;
|
||||
this.debugLog("UploadBase", "Fetching database cover", {
|
||||
databaseId: databaseID,
|
||||
apiTokenPreview: this.maskValue(notionAPI),
|
||||
});
|
||||
const response = await requestUrl({
|
||||
url: `https://api.notion.com/v1/databases/${databaseID}`,
|
||||
method: "GET",
|
||||
@@ -222,11 +208,6 @@ export abstract class UploadBase {
|
||||
this.handleRequestError(error, `Fetching database ${databaseID}`),
|
||||
);
|
||||
|
||||
this.debugLog("UploadBase", "Database cover response received", {
|
||||
status: response.status,
|
||||
hasCover: !!response.json.cover,
|
||||
});
|
||||
|
||||
if (response.json.cover && response.json.cover.external) {
|
||||
return response.json.cover.external.url;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ export async function uploadCommandNext(
|
||||
|
||||
const {notionAPI, databaseID} = dbDetails;
|
||||
console.log(`[uploadCommandNext] ${new Date().toISOString()} Triggered for file`, app.workspace.getActiveFile()?.path);
|
||||
logCommandDebug("uploadCommandNext", "Command invoked", {
|
||||
databaseId: databaseID,
|
||||
apiTokenPreview: `${notionAPI?.slice(0, 4) ?? ""}***`,
|
||||
});
|
||||
|
||||
// Check if the user has set up the Notion API and database ID
|
||||
if (notionAPI === "" || databaseID === "") {
|
||||
@@ -123,7 +119,7 @@ export async function uploadCommandNext(
|
||||
const {response} = res;
|
||||
if (response.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
|
||||
console.log(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`);
|
||||
|
||||
logCommandDebug("uploadCommandNext", "Sync succeeded", {
|
||||
filename: basename,
|
||||
status: response.status,
|
||||
@@ -154,10 +150,6 @@ export async function uploadCommandGeneral(
|
||||
|
||||
const {notionAPI, databaseID} = dbDetails;
|
||||
console.log(`[uploadCommandGeneral] ${new Date().toISOString()} Triggered for file`, app.workspace.getActiveFile()?.path);
|
||||
logCommandDebug("uploadCommandGeneral", "Command invoked", {
|
||||
databaseId: databaseID,
|
||||
apiTokenPreview: `${notionAPI?.slice(0, 4) ?? ""}***`,
|
||||
});
|
||||
|
||||
// Check if the user has set up the Notion API and database ID
|
||||
if (notionAPI === "" || databaseID === "") {
|
||||
@@ -204,7 +196,7 @@ export async function uploadCommandGeneral(
|
||||
const {response} = res;
|
||||
if (response.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
|
||||
console.log(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`);
|
||||
|
||||
logCommandDebug("uploadCommandGeneral", "Sync succeeded", {
|
||||
filename: basename,
|
||||
status: response.status,
|
||||
@@ -235,10 +227,6 @@ export async function uploadCommandCustom(
|
||||
|
||||
const {notionAPI, databaseID} = dbDetails;
|
||||
console.log(`[uploadCommandCustom] ${new Date().toISOString()} Triggered for file`, app.workspace.getActiveFile()?.path);
|
||||
logCommandDebug("uploadCommandCustom", "Command invoked", {
|
||||
databaseId: databaseID,
|
||||
apiTokenPreview: `${notionAPI?.slice(0, 4) ?? ""}***`,
|
||||
});
|
||||
|
||||
// Check if the user has set up the Notion API and database ID
|
||||
if (notionAPI === "" || databaseID === "") {
|
||||
@@ -285,7 +273,7 @@ export async function uploadCommandCustom(
|
||||
|
||||
if (response.status === 200) {
|
||||
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
|
||||
console.log(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`);
|
||||
|
||||
logCommandDebug("uploadCommandCustom", "Sync succeeded", {
|
||||
filename: basename,
|
||||
status: response.status,
|
||||
|
||||
Reference in New Issue
Block a user