diff --git a/manifest.json b/manifest.json index e5dda1d..0d17cec 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "slug": "markdown_it", "icon": "./icon.png", "description": "为 QQNT 提供 Markdown 渲染", - "version": "2.3.4", + "version": "2.3.5", "authors": [ { "name": "d0j1a_1701", @@ -16,7 +16,7 @@ "repo": "d0j1a1701/LiteLoaderQQNT-Markdown", "branch": "v4", "release": { - "tag": "2.3.4", + "tag": "2.3.5", "file": "Release.zip" } }, diff --git a/src/utils/logger_main.ts b/src/utils/logger_main.ts index 3f422f7..63ca4bb 100644 --- a/src/utils/logger_main.ts +++ b/src/utils/logger_main.ts @@ -7,7 +7,7 @@ declare const LiteLoader: LiteLoaderInterFace; export const LogPathHelper = { getLogFolderPath() { - return path.join(LiteLoader.plugins.markdown_it.path.plugin, 'log'); + return path.join(LiteLoader.plugins.markdown_it.path.data, 'log'); }, /** @@ -20,7 +20,7 @@ export const LogPathHelper = { // generate log file name if not received logFileName ??= (new Date().toISOString()).replaceAll(':', '-'); - return path.join(LiteLoader.plugins.markdown_it.path.plugin, 'log', `${logFileName}.log`); + return path.join(LogPathHelper.getLogFolderPath(), `${logFileName}.log`); } }; @@ -28,14 +28,18 @@ export const LogPathHelper = { * Generate a writer function that used to write log into log file. */ export function generateMainProcessLogerWriter() { - var logFolderPath = LogPathHelper.getLogFolderPath(); - var logFilePath = LogPathHelper.getLogFilePath(); + let logFolderPath = LogPathHelper.getLogFolderPath(); + let logFilePath = LogPathHelper.getLogFilePath(); console.log(`[markdown-it] logFolderPath: ${logFolderPath}`); console.log(`[markdown-it] logFilePath: ${logFilePath}`); // clear former log file - rmSync(logFolderPath, { recursive: true }); + try { + rmSync(logFolderPath, { recursive: true }); + } catch (e) { + console.error('[markdown-it] Failed to remove previous log file'); + } // create dir if not exists try { @@ -43,7 +47,8 @@ export function generateMainProcessLogerWriter() { mkdirSync(logFolderPath, { recursive: true }); } } catch (err) { - console.error(err); + console.error('[markdown-it] Failed to create log directory'); + return undefined; } var stream = createWriteStream(logFilePath, {