From e5a2980da8cf3625249ce6b782f45fbc57128375 Mon Sep 17 00:00:00 2001 From: fullex <106392080+0xfullex@users.noreply.github.com> Date: Sat, 10 Jan 2026 15:12:00 +0800 Subject: [PATCH] fix(logger): allow logging with unknown window source (#12406) * fix(logger): allow logging with unknown window source Previously, LoggerService would block all logging when window source was not initialized, which could swallow important business errors. Now it uses 'UNKNOWN' as the window source and continues logging. Co-Authored-By: Claude Opus 4.5 * chore(logger): update documentation links for LoggerService eslint Updated the ESLint configuration to point to the correct documentation for the unified LoggerService, ensuring users have access to the latest guides in both English and Chinese. --------- Co-authored-by: Claude Opus 4.5 --- eslint.config.mjs | 2 +- src/renderer/src/services/LoggerService.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 9eb20d1238..0667541aeb 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -84,7 +84,7 @@ export default defineConfig([ { selector: 'CallExpression[callee.object.name="console"]', message: - '❗CherryStudio uses unified LoggerService: 📖 docs/technical/how-to-use-logger-en.md\n❗CherryStudio 使用统一的日志服务:📖 docs/technical/how-to-use-logger-zh.md\n\n' + '❗CherryStudio uses unified LoggerService: 📖 docs/en/guides/logging.md\n❗CherryStudio 使用统一的日志服务:📖 docs/zh/guides/logging.md\n\n' } ] } diff --git a/src/renderer/src/services/LoggerService.ts b/src/renderer/src/services/LoggerService.ts index b0aa7f4b62..23f42eec01 100644 --- a/src/renderer/src/services/LoggerService.ts +++ b/src/renderer/src/services/LoggerService.ts @@ -113,9 +113,10 @@ class LoggerService { * @param data - Additional data to log */ private processLog(level: LogLevel, message: string, data: any[]): void { + let windowSource = this.window if (!this.window) { console.error('[LoggerService] window source not initialized, please initialize window source first') - return + windowSource = 'UNKNOWN' } const currentLevel = LEVEL_MAP[level] @@ -164,7 +165,7 @@ class LoggerService { if (currentLevel >= LEVEL_MAP[this.logToMainLevel] || forceLogToMain) { const source: LogSourceWithContext = { process: 'renderer', - window: this.window, + window: windowSource, module: this.module }