mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-12 08:59:02 +08:00
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 <noreply@anthropic.com> * 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 <noreply@anthropic.com>
This commit is contained in:
parent
5b5e190132
commit
e5a2980da8
@ -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'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user