Skip to content

feat: categorize shortcut plugin logs - #117

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
yixinshark:feat/shortcut-logging-category
Jul 31, 2026
Merged

feat: categorize shortcut plugin logs#117
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
yixinshark:feat/shortcut-logging-category

Conversation

@yixinshark

@yixinshark yixinshark commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the dde.services.shortcut Qt logging category for the shortcut plugin
  • migrate 237 plugin and debug-runner log calls to the categorized qC* macros
  • allow shortcut logs to be filtered independently inside the grouped service process

Test plan

  • cmake --build build --target plugin-dde-shortcut dde-shortcut-debug -j2
  • ctest --test-dir build -R "^shortcut-" --output-on-failure
  • verify runtime output contains [dde.services.shortcut]
  • verify QT_LOGGING_RULES="dde.services.shortcut=false" suppresses the category

Summary by Sourcery

Enhancements:

  • Add a shared logging category definition for the shortcut service/plugin and wire it into all shortcut-related components.

@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.

Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a dedicated Qt logging category dde.services.shortcut for the shortcut plugin and migrates existing logging calls across the plugin, backends, and debug runner to use categorized qC* macros so shortcut logs can be filtered independently.

Sequence diagram for categorized shortcut logging and filtering

sequenceDiagram
    actor Developer
    participant ShortcutPlugin
    participant QtLoggingSystem

    Developer->>QtLoggingSystem: setEnvironment(QT_LOGGING_RULES="dde.services.shortcut=false")
    ShortcutPlugin->>ShortcutPlugin: qCInfo(logShortcut, message)
    ShortcutPlugin->>QtLoggingSystem: emitLog(logShortcut, Info)
    QtLoggingSystem-->>ShortcutPlugin: [category dde.services.shortcut disabled] suppress output
Loading

File-Level Changes

Change Details Files
Introduce a shared Qt logging category for the shortcut subsystem and wire it into the build.
  • Add shortcutlogging.h/shortcutlogging.cpp defining QLoggingCategory logShortcut("dde.services.shortcut").
  • Expose the new logging files as part of SHORTCUT_COMMON_SOURCES in the shortcut plugin CMake configuration so both plugin and debug binaries link the category.
src/plugin-qt/shortcut/shortcutlogging.h
src/plugin-qt/shortcut/shortcutlogging.cpp
src/plugin-qt/shortcut/CMakeLists.txt
Migrate core shortcut/keybinding management logs to categorized logging macros.
  • Include shortcutlogging.h in keybindingmanager.cpp, shortcutmanager.cpp, customshortcuttransaction.cpp, gesturemanager.cpp, translationmanager.cpp, serviceactionexecutor.cpp, actionexecutor.cpp, main.cpp, and pluginshortcutmanager.cpp.
  • Replace qDebug/qInfo/qWarning/qCritical with qCDebug/qCInfo/qCWarning/qCCritical using logShortcut across keybinding registration, modification, rollback, config reload, gesture handling, translation loading, and service startup/teardown paths.
src/plugin-qt/shortcut/src/core/keybindingmanager.cpp
src/plugin-qt/shortcut/src/core/shortcutmanager.cpp
src/plugin-qt/shortcut/src/core/customshortcuttransaction.cpp
src/plugin-qt/shortcut/src/core/gesturemanager.cpp
src/plugin-qt/shortcut/src/core/translationmanager.cpp
src/plugin-qt/shortcut/src/core/actionexecutor.cpp
src/plugin-qt/shortcut/src/core/serviceactionexecutor.cpp
src/plugin-qt/shortcut/pluginshortcutmanager.cpp
src/plugin-qt/shortcut/src/main.cpp
Migrate configuration and custom shortcut persistence logs to the new logging category.
  • Include shortcutlogging.h in configloader.cpp and customshortcutstore.cpp.
  • Convert informational, debug, and warning messages about scanning configs, loading/removing configs, DConfig I/O, and custom shortcut save/update/remove/reset operations to use qCInfo/qCDebug/qCWarning(logShortcut).
src/plugin-qt/shortcut/src/config/configloader.cpp
src/plugin-qt/shortcut/src/config/customshortcutstore.cpp
Migrate X11/Wayland backend and gesture execution logs to the new logging category.
  • Include shortcutlogging.h in X11 and Wayland handlers (x11keyhandler, waylandkeyhandler, waylandgesturehandler, treelandshortcutwrapper, modifierkeymonitor, systemgestureproxy, specialkeyhandler, x11gestureactionexecutor).
  • Replace existing qDebug/qInfo/qWarning/qCritical statements for protocol availability, registration/grab failures, DBus call results, and gesture/window-move actions with categorized qC* calls bound to logShortcut.
src/plugin-qt/shortcut/src/backend/x11/x11keyhandler.cpp
src/plugin-qt/shortcut/src/backend/x11/x11gestureactionexecutor.cpp
src/plugin-qt/shortcut/src/backend/x11/modifierkeymonitor.cpp
src/plugin-qt/shortcut/src/backend/x11/systemgestureproxy.cpp
src/plugin-qt/shortcut/src/backend/wayland/waylandkeyhandler.cpp
src/plugin-qt/shortcut/src/backend/wayland/waylandgesturehandler.cpp
src/plugin-qt/shortcut/src/backend/wayland/treelandshortcutwrapper.cpp
src/plugin-qt/shortcut/src/backend/specialkeyhandler.cpp
Update plugin entry points to log via the new category.
  • Include shortcutlogging.h in the plugin entry file.
  • Convert plugin lifecycle qInfo/qCritical messages in DSMRegister/DSMUnRegister to qCInfo/qCCritical(logShortcut).
src/plugin-qt/shortcut/plugin.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

@yixinshark
yixinshark force-pushed the feat/shortcut-logging-category branch from f20ff8f to acdb5f5 Compare July 30, 2026 02:39
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: robertkill, yixinshark

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 a dedicated Qt logging category for the shortcut plugin.
- Route 237 plugin and debug-runner log calls through qC* macros.
- Use dde.services.shortcut so grouped service logs can be filtered by plugin.
- Share the category source definition between the plugin and debug targets.

为快捷键插件增加独立的 Qt 日志分类。
- 将插件及调试程序中的 237 处日志调用迁移到 qC* 宏。
- 使用 dde.services.shortcut,使分组服务日志可以按插件过滤。
- 在插件与调试目标之间共享日志分类的源码定义。

Log: categorize shortcut plugin logs
Change-Id: Id199e18fad29b54e6d63b399570ddfd8d027c3ca
@yixinshark
yixinshark force-pushed the feat/shortcut-logging-category branch from acdb5f5 to 590d289 Compare July 31, 2026 08:27
@yixinshark

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit ead0cba into linuxdeepin:master Jul 31, 2026
7 of 8 checks passed
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码通过引入QLoggingCategory重构了快捷键模块的日志系统,整体实现规范且无安全漏洞
逻辑正确且符合Qt日志管理的最佳实践,有效提升了系统级日志的可过滤性与可维护性

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

代码在shortcutlogging.h中使用Q_DECLARE_LOGGING_CATEGORY(logShortcut)声明分类,在shortcutlogging.cpp中使用Q_LOGGING_CATEGORY(logShortcut, "dde.services.shortcut")进行定义,符合Qt规范。各文件中的qDebug等函数被正确替换为qCDebug(logShortcut)等形式,参数传递无误。CMakeLists.txt中也正确添加了新增的源文件和头文件。
潜在问题:无
建议:无需修改

  • 2.代码质量(优秀)✓

引入统一的日志分类dde.services.shortcut,极大地方便了系统级的日志过滤与调试,避免了之前不同模块可能出现的日志混杂问题。头文件使用了#pragma once进行保护,且包含了SPDX版权声明,符合开源规范。
潜在问题:无
建议:可以考虑在未来进一步细分日志子分类(如输入、手势、配置等),以提供更精细的日志控制能力

  • 3.代码性能(无性能问题)✓

QLoggingCategory允许在运行时动态控制日志级别,当关闭某些级别的日志输出时(如Debug级别),相关的参数构造和输出操作将被完全跳过,相比静态的qDebug具有更好的运行时性能表现。
潜在问题:无
建议:无需修改

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次变更仅为日志系统的重构,不涉及外部输入处理、内存管理或权限操作,未引入任何安全风险。

  • 建议:无需修复

■ 【改进建议代码示例】

// 当前代码已经非常完善,无需修复。以下为未来可能的日志子分类扩展示例:

// shortcutlogging.h
#pragma once

#include <QLoggingCategory>

Q_DECLARE_LOGGING_CATEGORY(logShortcut)
Q_DECLARE_LOGGING_CATEGORY(logShortcutInput)
Q_DECLARE_LOGGING_CATEGORY(logShortcutGesture)
Q_DECLARE_LOGGING_CATEGORY(logShortcutConfig)

// shortcutlogging.cpp
#include "shortcutlogging.h"

Q_LOGGING_CATEGORY(logShortcut, "dde.services.shortcut")
Q_LOGGING_CATEGORY(logShortcutInput, "dde.services.shortcut.input")
Q_LOGGING_CATEGORY(logShortcutGesture, "dde.services.shortcut.gesture")
Q_LOGGING_CATEGORY(logShortcutConfig, "dde.services.shortcut.config")

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