fix duplicated logs caused by importing seafobj - #908
Merged
Merged
Conversation
seafile-dev
reviewed
Aug 25, 2026
seafile-dev
left a comment
There was a problem hiding this comment.
Verdict: Comment
Warnings:
- 日志去重的根因处理正确:启动时会移除依赖(如 seafobj)预先注册到 root logger 的 handler,并仅保留 dtable-events 的 handler。当前缺少覆盖该回归场景的自动化测试,详见行内评论。
Suggested fix: 增加模拟外部 root handler 的测试,并断言同一日志仅写入一次。
| root_logger = logging.getLogger() | ||
|
|
||
| # Replace handlers installed by imported dependencies such as seafobj. | ||
| for handler in root_logger.handlers[:]: |
There was a problem hiding this comment.
[Warning] 缺少重复日志回归测试
Why this matters:
此处通过清理依赖(如 seafobj)预先注册到 root logger 的 handler 来消除重复输出,但当前没有测试覆盖该启动顺序。后续调整日志初始化或升级依赖时,重复日志可能无提示地回归。
Suggested fix: 新增测试:预先向 root logger 注册一个外部 StreamHandler,执行 LogConfigurator 后断言旧 handler 已移除,并验证一条日志在目标输出中只出现一次。
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.
No description provided.