chore: loggingrules config move to preference

org.deepin.dtk.logginerules ==> org.deepin.dtk.preference
如果 DConfig 无效就不清空环境变量
This commit is contained in:
ck 2024-05-10 10:57:17 +08:00 committed by mike
parent f21de0440b
commit c876a2a2a9
1 changed files with 11 additions and 11 deletions

View File

@ -133,18 +133,8 @@ void DLogManager::initLoggingRules(const QString &appId)
return;
}
// QT_LOGGING_RULES环境变量设置日志的优先级最高
// QLoggingRegistry 初始化时会获取 QT_LOGGING_RULES 的值并保存,后续重置了环境变量 QLoggingRegistry 不会进行同步
// 需要在 QLoggingRegistry 初始化之前重置 QT_LOGGING_RULES 的值
QByteArray logRules = qgetenv("QT_LOGGING_RULES");
qunsetenv("QT_LOGGING_RULES");
if (!logRules.isEmpty()) {
QLoggingCategory::setFilterRules(logRules.replace(";", "\n"));
}
Q_D(DLogManager);
d->m_loggingRulesConfig = DConfig::create(appId, "org.deepin.dtk.loggingrules");
d->m_loggingRulesConfig = DConfig::create(appId, "org.deepin.dtk.preference");
if (!d->m_loggingRulesConfig) {
qWarning() << "Create logging rules dconfig object failed, logging rules won't take effect";
return;
@ -157,6 +147,16 @@ void DLogManager::initLoggingRules(const QString &appId)
return;
}
// QT_LOGGING_RULES环境变量设置日志的优先级最高
// QLoggingRegistry 初始化时会获取 QT_LOGGING_RULES 的值并保存,后续重置了环境变量 QLoggingRegistry 不会进行同步
// 需要在 QLoggingRegistry 初始化之前重置 QT_LOGGING_RULES 的值
QByteArray logRules = qgetenv("QT_LOGGING_RULES");
qunsetenv("QT_LOGGING_RULES");
if (!logRules.isEmpty()) {
QLoggingCategory::setFilterRules(logRules.replace(";", "\n"));
}
auto updateLoggingRules = [d](const QString & key) {
if (key != RULES_KEY)
return;