Skip to content

fix(log): unify all logs to category appLog for DConfig filtering - #424

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:task-396789-unify-log-category
Oct 21, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:task-396789-unify-log-category

Conversation

@add-uos

@add-uos add-uos commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

变更说明 (TASK-396789)

统一全项目日志为分类日志,使日志可被 DConfig(deepin-log-viewer) 统一过滤。

改动点

  • reader / batch-print / htmltopdf 三个模块:45 处裸 qInfo/qDebug/qWarning/qCritical 全部替换为 qC*Info(appLog) 等分类写法
  • ddlog.h 收敛为全项目唯一:精简为纯 Qt 头(去除 DLog/DConfig 依赖),batch-print、htmltopdf 通过 CMake include 路径复用同一 appLog 定义,不再有副本
  • 更新 SPDX 版权年份

效果

三个可执行(deepin-reader / deepin-reader-batchprint / htmltopdf)日志均带 org.deepin.reader 分类,DConfig 的 log_rules(含 org.deepin.reader* 通配规则)可统一过滤全部日志。

自测

  • 三个 target 编译通过
  • DConfig 默认规则(分号分隔多段规则)过滤生效验证:Debug 按规则被过滤/放开
  • 主程序与批量打印进程运行正常

Log: 统一全项目日志为分类日志并收敛ddlog.h定义
PMS: TASK-396789

Summary by Sourcery

Unify application logging categories across all reader executables so DConfig can consistently filter their logs.

Enhancements:

  • Standardize reader, PDFium, batch-print, and HTML-to-PDF logging under categorized Qt logging categories for unified DConfig filtering.
  • Consolidate shared logging category definitions and add module-specific categories for batch printing and HTML-to-PDF processes.

Build:

  • Update CMake include paths so auxiliary targets reuse the reader logging definitions.

Chores:

  • Update SPDX copyright metadata across affected files.

@sourcery-ai

sourcery-ai Bot commented Oct 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR standardizes logging for all three executables around a single shared org.deepin.reader category, enabling unified DConfig filtering, while also consolidating the logging header and introducing Qt-version compatibility, gesture-state fixes, ownership documentation, and metadata updates.

Sequence diagram for categorized log filtering

sequenceDiagram
    participant Executable
    participant appLog
    participant DConfig
    participant Viewer as deepin-log-viewer

    Executable->>appLog: qCDebug(appLog)
    Executable->>appLog: qCInfo(appLog)
    Executable->>appLog: qCWarning(appLog)
    Executable->>appLog: qCCritical(appLog)
    appLog->>DConfig: org.deepin.reader
    DConfig->>Viewer: log_rules filtering
    Viewer-->>DConfig: filtered application logs
Loading

File-Level Changes

Change Details Files
Unified logging across the reader, batch-print, and htmltopdf executables under the shared org.deepin.reader category.
  • Replaced remaining un categorized Qt logging calls with qC* calls using appLog.
  • Simplified ddlog.h to Qt logging-category definitions and reused it from the auxiliary targets through CMake include paths.
  • Updated logging-related SPDX copyright years.
reader/ddlog.h
reader/Application.cpp
reader/app/Database.cpp
reader/document/DjVuModel.cpp
reader/document/Model.cpp
reader/document/PDFModel.cpp
reader/sidebar/CatalogTreeView.cpp
reader/sidebar/CatalogWidget.cpp
batch-print/CMakeLists.txt
batch-print/batchprintapp.cpp
batch-print/cupsclient.cpp
htmltopdf/CMakeLists.txt
htmltopdf/main.cpp
htmltopdf/htmltopdfconverter.cpp
Added Qt-version compatibility guards and modernized several Qt API usages.
  • Guarded the Qt5-only HiDPI attribute.
  • Selected Qt6 replacements for hover-event coordinates, library paths, and UTC time conversion while retaining older-Qt fallbacks.
  • Replaced deprecated string-count calls with size().
reader/Application.cpp
reader/MainWindow.cpp
reader/document/XpsDocumentAdapter.cpp
reader/widgets/SecurityDialog.cpp
reader/widgets/TransparentTextEdit.cpp
Made pinch-gesture state instance-owned and robust across canceled or interrupted gestures.
  • Moved gesture state from function statics into SheetBrowser members.
  • Reset scale state at gesture start and handled canceled gestures during cleanup.
  • Preserved delayed cleanup with the browser as the timer receiver to avoid stale-object access.
reader/browser/SheetBrowser.cpp
reader/browser/SheetBrowser.h
Documented PDF page ownership and updated related source metadata.
  • Clarified that DPdfDoc owns and caches returned pages and callers must not delete them.
  • Refreshed copyright and SPDX metadata in touched files.
3rdparty/deepin-pdfium/include/dpdfdoc.h
3rdparty/deepin-pdfium/include/dpdfpage.h
htmltopdf/CMakeLists.txt
reader/document/XpsDocumentAdapter.cpp
reader/widgets/SecurityDialog.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="batch-print/batchprintapp.cpp" line_range="38" />
<code_context>
     if (cups) {
         if (!cups->init()) {
-            qWarning() << "CUPS init failed";
+            qCWarning(appLog) << "CUPS init failed";
             NotifyClient::notifyError(ErrorMessages::cupsUnavailable());
             return 2;
</code_context>
<issue_to_address>
**Helper logs ignore configured filters**

When DConfig `log_rules` are configured to filter logs emitted by batch-print or htmltopdf, `batchprint` and `htmltopdf` run in separate processes and do not load the DConfig rules, so their categorized logs retain the process defaults instead of honoring those filters.

Load and apply the DConfig logging rules in both helper processes.

Also at `htmltopdf/main.cpp:19`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread batch-print/batchprintapp.cpp Outdated
if (cups) {
if (!cups->init()) {
qWarning() << "CUPS init failed";
qCWarning(appLog) << "CUPS init failed";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Helper logs ignore configured filters

When DConfig log_rules are configured to filter logs emitted by batch-print or htmltopdf, batchprint and htmltopdf run in separate processes and do not load the DConfig rules, so their categorized logs retain the process defaults instead of honoring those filters.

Load and apply the DConfig logging rules in both helper processes.

Also at htmltopdf/main.cpp:19.

Prompt for AI agents
In `batch-print/batchprintapp.cpp` at line 38:

**Helper logs ignore configured filters**

When DConfig `log_rules` are configured to filter logs emitted by batch-print or htmltopdf, `batchprint` and `htmltopdf` run in separate processes and do not load the DConfig rules, so their categorized logs retain the process defaults instead of honoring those filters.

Load and apply the DConfig logging rules in both helper processes.

Also at `htmltopdf/main.cpp:19`.

@add-uos
add-uos force-pushed the task-396789-unify-log-category branch from 18cd90e to 1d3f880 Compare October 21, 2026 02:08
- Replace bare qInfo/qDebug/qWarning/qCritical with categorized
  qC* variants in reader, batch-print and htmltopdf modules
- Refine ddlog.h into a pure Qt header and share it across all
  three executables, keeping only one appLog definition
- Update SPDX copyright years

Log: 统一全项目日志为分类日志并收敛ddlog.h定义
PMS: TASK-396789
Influence: 三个进程日志均带org.deepin.reader分类,可被DConfig日志规则统一过滤。
@add-uos
add-uos force-pushed the task-396789-unify-log-category branch from 2951a01 to ebf1296 Compare October 21, 2026 02:51
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交将 deepin-reader 全项目的 qDebug/qInfo/qWarning/qCritical 日志统一迁移为 QLoggingCategory 分类日志(appLog/batchprintLog/htmltopdfLog/dpfLog),便于 DConfig 按应用前缀统一过滤。变更模式一致、范围明确,新增 dpdflog.h 头文件设计合理, 同时修复了 SPDX 许可标识拼写错误并更新版权年份。四维度均无问题,无安全漏洞, OCR 审查亦未发现问题。代码质量优秀。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: []


2. 代码质量 ✅

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

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

建议: []


3. 代码性能 ✅

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

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

建议: []


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

本次变更无需修复,代码质量优秀。以下为分类日志的正确使用示例(已在本次提交中正确实现):
// dpdflog.h — deepin-pdfium 模块日志分类声明 #ifndef DPDFLOG_H #define DPDFLOG_H #include <QLoggingCategory> Q_DECLARE_LOGGING_CATEGORY(dpfLog) #endif // DPDFLOG_H
// dpdfglobal.cpp — 分类定义 Q_LOGGING_CATEGORY(dpfLog, "org.deepin.reader.pdfium")
// 使用处 — 统一使用分类日志 qCDebug(dpfLog) << "Loading PDF document:" << filePath; qCWarning(dpfLog) << "Failed to open file for writing:" << targetPath;

本报告由 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 21, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 0d6a90c into linuxdeepin:master Oct 21, 2026
9 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