🐛 修复开发环境 debug 日志持久化#1592
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
本 PR 旨在修复开发构建(pnpm dev)下持久化日志的默认级别不符合预期的问题,并统一/修正扩展页面(React 页面)向 service worker 投递日志的消息路由前缀,避免日志消息因路由不匹配而被静默丢弃。这与 ScriptCat 多进程消息通信架构(页面 → service worker)一致。
Changes:
- 调整
LoggerCore持久化日志默认级别:开发环境默认为debug,其他环境默认为info,并保持显式config.level的最高优先级。 - 为页面侧日志写入器增加
serviceWorker/logger路由工厂方法,并在多个页面入口统一使用该路由。 - 新增
LoggerCore默认持久化级别与页面日志路由的回归测试用例。
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/pages/popup/main.tsx | 页面侧日志 writer 改为走 serviceWorker/logger 路由,避免消息丢失 |
| src/pages/options/main.tsx | 同上:options 页日志 writer 路由修正 |
| src/pages/install/main.tsx | 同上:install 页日志 writer 路由修正 |
| src/pages/import/main.tsx | 同上:import 页日志 writer 路由修正 |
| src/pages/confirm/main.tsx | 同上:confirm 页日志 writer 路由修正 |
| src/pages/batchupdate/main.tsx | 同上:batchupdate 页日志 writer 路由修正 |
| src/app/logger/message_writer.ts | 引入强类型 LoggerAction,新增 serviceWorker() 工厂以规范页面日志投递路由 |
| src/app/logger/message_writer.test.ts | 新增页面日志必须投递到 serviceWorker/logger 的回归测试 |
| src/app/logger/core.ts | 调整持久化 level 的默认值逻辑(dev=debug,其它=info),保留显式配置优先 |
| src/app/logger/core.test.ts | 新增持久化 level 默认行为与显式覆盖行为的回归测试 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改内容
debug,生产及其他环境仍为infoconfig.level的最高优先级,默认仍不持久化traceserviceWorker/路由前缀、导致消息静默丢失的问题验证
pnpm exec vitest run --no-coverage --reporter=verbose src/app/logger/core.test.ts src/app/logger/message_writer.test.ts src/app/service/service_worker/log.test.ts(3 files / 10 tests passed)pnpm run lint(Prettier、TypeScript、ESLint 通过)git diff --checkFixes #1560