Skip to content

refactor: reduce log level from info to debug#68

Merged
mhduiy merged 1 commit intolinuxdeepin:masterfrom
mhduiy:log
Sep 26, 2025
Merged

refactor: reduce log level from info to debug#68
mhduiy merged 1 commit intolinuxdeepin:masterfrom
mhduiy:log

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented Sep 26, 2025

Changed logging statements from qCInfo to qCDebug in policy checking and D-Bus hook functions to reduce log noise in production environments. Added DTK logging framework dependencies and initialization to enhance logging capabilities. The info-level logs were too verbose for normal operation but are still useful for debugging purposes.

The changes include:

  1. Replace qCInfo with qCDebug in policy.cpp for permission checking logs
  2. Replace qCInfo with qCDebug in qtdbushook.cpp for D-Bus message processing logs
  3. Add DTK Core component dependency in CMakeLists.txt
  4. Register console and journal appenders in main.cpp for DTK logging

refactor: 将日志级别从信息降为调试

将策略检查和D-Bus钩子函数中的日志语句从qCInfo改为qCDebug,以减少生产环境
中的日志噪音。添加DTK日志框架依赖和初始化以增强日志功能。信息级别的日志
在正常操作中过于冗长,但在调试时仍然有用。

更改包括:

  1. 在policy.cpp中将权限检查日志从qCInfo改为qCDebug
  2. 在qtdbushook.cpp中将D-Bus消息处理日志从qCInfo改为qCDebug
  3. 在CMakeLists.txt中添加DTK Core组件依赖
  4. 在main.cpp中注册控制台和日志应用器以支持DTK日志

@mhduiy mhduiy requested a review from 18202781743 September 26, 2025 09:10
18202781743
18202781743 previously approved these changes Sep 26, 2025
Changed logging statements from qCInfo to qCDebug in policy checking
and D-Bus hook functions to reduce log noise in production environments.
Added DTK logging framework dependencies and initialization to enhance
logging capabilities. The info-level logs were too verbose for normal
operation but are still useful for debugging purposes.

The changes include:
1. Replace qCInfo with qCDebug in policy.cpp for permission checking
logs
2. Replace qCInfo with qCDebug in qtdbushook.cpp for D-Bus message
processing logs
3. Add DTK Core component dependency in CMakeLists.txt
4. Register console and journal appenders in main.cpp for DTK logging

refactor: 将日志级别从信息降为调试

将策略检查和D-Bus钩子函数中的日志语句从qCInfo改为qCDebug,以减少生产环境
中的日志噪音。添加DTK日志框架依赖和初始化以增强日志功能。信息级别的日志
在正常操作中过于冗长,但在调试时仍然有用。

更改包括:
1. 在policy.cpp中将权限检查日志从qCInfo改为qCDebug
2. 在qtdbushook.cpp中将D-Bus消息处理日志从qCInfo改为qCDebug
3. 在CMakeLists.txt中添加DTK Core组件依赖
4. 在main.cpp中注册控制台和日志应用器以支持DTK日志
@deepin-ci-robot
Copy link

deepin pr auto review

根据提供的代码差异,我来对代码进行审查,并提出改进意见:

  1. 日志级别优化:
  • 在 qtdbushook.cpp 中,所有日志级别从 qCInfo 改为了 qCDebug
    优点:这减少了日志输出的冗余度,提高了性能,因为调试信息通常在生产环境中不需要显示。
    建议:确保这些调试信息确实只在调试阶段需要,并且不会遗漏任何重要的信息。可以考虑为关键状态转换(如服务注册/注销)保留 qCInfo 级别的日志。
  1. 依赖管理:
  • 在 CMakeLists.txt 中添加了 Dtk6::Core 依赖
    建议:
    1. 确保项目中所有使用 Dtk6::Core 的地方都正确包含了相关头文件
    2. 考虑添加版本检查,确保 Dtk6 的版本兼容性
    3. 在文档中明确说明对 Dtk6 的依赖关系
  1. 日志系统集成:
  • 在 main.cpp 中添加了 DLog 相关代码
    建议:
    1. 考虑添加日志格式化配置,使日志输出更规范
    2. 可以添加日志文件滚动配置,防止日志文件过大
    3. 建议为不同模块设置不同的日志级别,便于问题排查
  1. 性能考虑:
  • 在 qtdbushook.cpp 中,频繁的字符串拼接(如 QString("--service: %1 will unregister in %2 minutes!"))可能会影响性能
    建议:考虑使用预定义的日志模板或使用 QString::asprintf 优化字符串拼接性能
  1. 代码安全性:
  • 在 qtdbushook.cpp 中,直接访问 serviceObj->policy 成员变量存在潜在风险
    建议:添加适当的空值检查,防止空指针解引用
    if (!serviceObj || !serviceObj->policy) {
        qCCritical(dsm_hook_qt) << "Invalid service object or policy";
        return;
    }
  1. 错误处理:
  • 在 qtdbushook.cpp 中的错误处理较为简单
    建议:
    1. 对 registerService() 和 restartTimer() 等操作添加错误处理
    2. 考虑使用异常处理机制来管理关键流程中的错误
  1. 代码可维护性:
  • 建议将重复的日志消息提取为常量或宏定义,提高代码可维护性
  • 可以考虑将服务注册和定时器相关的逻辑封装为独立的方法
  1. 配置管理:
  • 建议将超时时间等配置参数提取到配置文件中,而不是硬编码在代码中
  1. 线程安全:
  • 在 qtdbushook.cpp 中,需要注意多线程环境下的安全性
    建议:
    1. 对共享资源访问添加适当的同步机制
    2. 确保 ServiceBase 对象的生命周期管理是线程安全的
  1. 代码风格:
  • 建议统一代码风格,特别是注释风格和空行使用
  • 可以考虑使用更明确的变量名,提高代码可读性

以上建议旨在提高代码的质量、性能和可维护性。根据实际项目需求,可以选择性地实施这些建议。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, mhduiy

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

@mhduiy mhduiy merged commit 74e1f04 into linuxdeepin:master Sep 26, 2025
15 of 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