Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loggingrules dconfig support (cherry-pick from gerrit) #413

Merged
merged 9 commits into from
May 17, 2024

Conversation

kegechen
Copy link
Contributor

@kegechen kegechen commented May 9, 2024

  • 允许基于dtk开发的应用动态控制其日志输出等级
  • lshw查询内存大小时返回多元素数组,修正解析过程
  • 从文件中读取deepinType和productType值时因为权限问题会失败
  • 增加registerLoggingRulesWatcher接口
  • 修复计算 build 版本号错误的问题
  • 修复日志格式时间戳显示异常问题

linuxdeepin/dtkcommon#70

deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 9, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
@deepin-bot
Copy link
Contributor

deepin-bot bot commented May 9, 2024

Doc Check bot
🟢 Document Coverage Check Passed!

@kegechen
Copy link
Contributor Author

kegechen commented May 9, 2024

@Whale107 @Groveer @993381

@kegechen kegechen requested a review from zccrs May 9, 2024 10:19
src/log/LogManager.cpp Outdated Show resolved Hide resolved
include/log/LogManager.h Outdated Show resolved Hide resolved
src/dsysinfo.cpp Show resolved Hide resolved
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 10, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
src/log/LogManager.cpp Outdated Show resolved Hide resolved
src/log/LogManager.cpp Outdated Show resolved Hide resolved
src/log/LogManager.cpp Outdated Show resolved Hide resolved
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 11, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
@kegechen kegechen requested review from 18202781743 and zccrs May 11, 2024 00:35
src/log/LogManager.cpp Outdated Show resolved Hide resolved
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 11, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 11, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
@kegechen kegechen requested a review from zccrs May 11, 2024 07:54
src/log/LogManager.cpp Outdated Show resolved Hide resolved
src/log/LogManager.cpp Outdated Show resolved Hide resolved
src/log/LogManager.cpp Outdated Show resolved Hide resolved
src/log/LogManager.cpp Outdated Show resolved Hide resolved
src/log/LogManager.cpp Outdated Show resolved Hide resolved
src/log/LogManager.cpp Outdated Show resolved Hide resolved
src/log/LogManager.cpp Outdated Show resolved Hide resolved
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 14, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 14, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
@kegechen kegechen requested a review from zccrs May 14, 2024 08:21
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 14, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 14, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Groveer, kegechen, zccrs

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

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

updateLoggingRules();
}

void DLogManagerPrivate::updateLoggingRules()
Copy link
Contributor

@18202781743 18202781743 May 14, 2024

Choose a reason for hiding this comment

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

在应用不重启的情况下,不能重置之前设置的值了,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

似的,reset 之后,isDefaultValue 是 true,也就是说不能用reset的方式来清空rules,只能删除的方式清空

@deepin-bot
Copy link
Contributor

deepin-bot bot commented May 16, 2024

TAG Bot

New tag: 5.6.29
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #415

Whale107 and others added 9 commits May 17, 2024 09:55
在运行中,不需要重启应用,也可以通过配置项控制日志输出等级
注: 应用的applicationName 需要和dconfig安装时的appid等同方可识别
配置规则等同于QT_LOGGING_RULES

注意:由于 dtk/dtk6 的存在 meta 文件 在 libdtkdata 中安装

Log: 允许基于dtk开发的应用动态控制其日志输出等级
Influence: 允许基于dtk开发的应用动态控制其日志输出等级
Task: https://pms.uniontech.com/task-view-307567.html
      https://pms.uniontech.com/task-view-305899.html
调整json结果解析过程

Log: 在不同场景下lshw可能返回多个元素
Influence: DSysInfo::memoryInstalledSize解析过程
Bug: https://pms.uniontech.com/bug-view-228681.html
Change-Id: I51030f037fa272ef9d510265524e5ec934c1f9bd
安装了三方管控应用时,从文件中读取deepinType和productType值时因为权限问题会失败,需要重新读取一次

Log: 修复第一次读取配置文件失败导致无法显示系统版本和说明问题
Influence: 正常显示版本和说明
功能:监听 dconfig 的值然后设置应用的日志级别
目的:
1.取消QT_LOGGING_RULES需要在创建 application之前处理
因为QLoggingRegistry在构造函数中获取环境变量的值后不会监听环境变量的变化.
目前直接使用applicationName当做appId 的做法不可行.
2.不和应用的 applicationName耦合目前大部分应用的applicationName和dconfig
的appId是不一样的,需要修改应用的名字
可能存在多个 application 使用通过一个 dconfig
的情况,修改applicantionName的方法不可行.
PS:从 DConfig 获取默认 appId 的逻辑上看, DSGApplication应用会有问题
3.开发者可以选择是否需要设置以及监听日志级别变动

Log:
Task: https://pms.uniontech.com/task-view-303379.html
场景如下(完整版本号 -> 构建版本号):
5.6.8 -> 0
5.6.8.7 -> 7
5.6.8+u001 -> 1
5.6.8.7+u001 -> 7
5.6.8.0+u001 -> 0

Log:
Influence: 构建版本号(BUILD_VERSION )
DeepinType类型增加军用版

Log: DeepinType类型增加军用版
Task: https://pms.uniontech.com/task-view-316703.html
Influence: DeepinType类型
Change-Id: I9db5a3d14eebab69b5cac44fbfb0d2a09d8d84c3
适配qt的日志格式
%{time yyyy-MM-ddTHH:mm:ss.zzz} ==> %{time}{yyyy-MM-ddTHH:mm:ss.zzz}

Log: 修复日志格式时间戳显示异常问题
Bug: https://pms.uniontech.com/bug-view-236239.html
Influence: 使用DLogManager的应用日志输出格式
org.deepin.dtk.logginerules ==> org.deepin.dtk.preference
如果 DConfig 无效就不清空环境变量
- 移除相关接口, 默认启用(可以用 DTK_DISABLED_LOGGING_RULES 禁用)
- 优先使用 dsgAppId , 用户可以通过 DTK_LOGGING_FALLBACK_APPID 指定
  fallbackAppId
- 有配置过 rules 时, 优先使用(即非默认值优先)
- fallbackConfig 发生变化时会检查 dsgConfig 是否修改过,是则忽略
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request May 17, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

关键摘要:

  • createDConfig函数中,当appId为空时返回nullptr,但未检查DConfig::create是否成功创建配置,可能会导致后续代码在尝试访问config时出现未定义行为。
  • initLoggingRules函数中使用了qEnvironmentVariableIsSet来检查环境变量DTK_DISABLED_LOGGING_RULES,但没有在代码中看到对这一变量的任何操作,可能存在未完成的功能。
  • updateLoggingRules函数中,var = m_dsgConfig->value(RULES_KEY);var = m_fallbackConfig->value(RULES_KEY);这两行代码路径没有注释说明其逻辑,可能会让人困惑。
  • QLoggingCategory::setFilterRules函数的参数使用了replace(";", "\n")来处理分号,但没有解释为什么需要这样做,可能需要更多的上下文信息。

是否建议立即修改:

这些问题可能会影响代码的可读性、可维护性和功能的正确性。建议在合并代码前进行充分的检查和修改。

@kegechen kegechen merged commit 653f6dc into linuxdeepin:master May 17, 2024
17 of 21 checks passed
kegechen pushed a commit to linuxdeepin/dtk6core that referenced this pull request May 24, 2024
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#413
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.

9 participants