Skip to content

feat(log): categorize logging and support dynamic log rules via DConfig - #682

Merged
deepin-bot[bot] merged 3 commits into
linuxdeepin:masterfrom
add-uos:feat/editor-debugsource
Oct 24, 2026
Merged

deepin-bot[bot] merged 3 commits into
linuxdeepin:masterfrom
add-uos:feat/editor-debugsource

Conversation

@add-uos

@add-uos add-uos commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary / 概述

调试模式(deepin-debug-config)适配:日志分类化 + DConfig 动态日志级别。

  • 日志分类化:全量 qDebug/qInfo/qWarning(52 个文件 3689 处)改为 qCDebug/qCInfo/qCWarning(appLog),分类 org.deepin.editor(新增 src/ddlog.h)
  • 动态日志监听:新增 src/logger.{h,cpp}(MLogger,参考 deepin-reader),在 main() 中于任何日志打印前实例化,从 DConfig org.deepin.editor/log_rules 读取规则并监听 valueChanged,运行中动态切换日志级别
  • DConfig meta:misc/configs/org.deepin.editor.json 新增 log_rules 配置项(默认 warning=true),沿用现有 CMake 安装规则
  • 修复静态初始化泄漏:encoding.cpp 的 locale 探测从静态初始化改为首次使用时初始化,避免在 main() 之前(日志规则尚未生效)打印调试日志

daemon/ 为遗留未打包的 qmake 代码(Qt5 + polkit-qt5,未随 deb 构建/安装),本次不改动。

Verification / 验证

  • cmake -B build-dbgcfg -DCMAKE_BUILD_TYPE=Debug && cmake --build 编译通过
  • 四级实测(dde-dconfig --set -a org.deepin.editor -r org.deepin.editor -k log_rules):
    • debug:qCDebug/qCInfo/qCWarning 全部输出(启动 200+ 行)
    • info:仅 qCInfo/qCWarning,qCDebug 无泄漏
    • warning:仅 qCWarning
    • 运行中切换:应用保持运行,dde-dconfig 改规则后新日志立即按新级别输出(valueChanged 生效)
  • 输出中除本应用分类日志外仅有 DTK 库自身一行 dtk.core.dsg 配置读取日志,无 Qt 框架日志混入

Log: 调试模式适配——日志分类化与动态日志级别

Categorize all qDebug/qInfo/qWarning calls into qCDebug/qCInfo/qCWarning
with the org.deepin.editor category, add MLogger to read log_rules from
DConfig (org.deepin.editor) and watch changes at runtime, and add the
log_rules key to the DConfig meta file. This enables the deepin debug
mode (deepin-debug-config) to dynamically switch log levels.

Note: the daemon/ directory is legacy unpackaged qmake code (built for
Qt5 with polkit-qt5, not shipped in the deb) and is left unchanged.

日志分类化改造:存量 qDebug/qInfo/qWarning 全部改为带 org.deepin.editor
分类的 qCDebug/qCInfo/qCWarning;新增 MLogger 从 DConfig 读取 log_rules
并监听变更,支持调试模式运行中动态调整日志级别;DConfig meta 增加
log_rules 配置项。

Log: 调试模式适配——日志分类化与动态日志级别
Influence: 应用日志可按 org.deepin.editor 分类过滤,日志级别可动态切换
…ogging

The static initializer getLocaleNum() logged via qCDebug before main()
runs, before MLogger applies dynamic log rules, leaking debug lines at
info/warning levels. Convert to lazy initialization.

Log: 修复 info/warning 级别下启动期日志泄漏
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Sorry @add-uos, your pull request is larger than the review limit of 150,000 diff characters

…orks

QT_NO_DEBUG_OUTPUT makes QLoggingCategoryMacroHolder<QtDebugMsg>::
IsOutputEnabled statically false at compile time, turning qCDebug into
a hard no-op. The packaged Release deb therefore can only ever print
qCInfo/qCWarning even with the debug mode switched to the debug level.
Disabled categorized logs cost one boolean check per call (Qt lazily
evaluates arguments), so keep them compiled in; deepin-reader, the
reference implementation, does not compile them out either.

Log: 修复打包版 Release 构建调试模式无法输出 debug 级日志
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交将全应用的 qDebug/qInfo/qWarning 统一迁移为 Qt 分类日志(qCDebug/qCInfo/qCWarning),并通过 DConfig 支持动态日志规则,属于日志架构重构。变更涉及 30 个文件,核心新增 ddlog.h 头文件、encoding.cpp 延迟初始化优化、CMakeLists.txt 移除 QT_NO_DEBUG_OUTPUT 定义。四维度均无问题,无安全漏洞,代码逻辑正确,性能无负面影响。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例


本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos

add-uos commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 6093a6f into linuxdeepin:master Oct 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants