-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add deepin-system-monitor log adaptation work
add deepin-system-monitor log adaptation work Log: add deepin-system-monitor log adaptation work Task: https://pms.uniontech.com/task-view-341559.html
- Loading branch information
1 parent
31c1575
commit 0266add
Showing
72 changed files
with
2,229 additions
and
1,288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"magic": "dsg.config.meta", | ||
"version": "1.0", | ||
"contents": { | ||
"log_rules": { | ||
"value": "*.debug=false;*.info=false;*.warning=true", | ||
"serial": 0, | ||
"flags": [ | ||
"global" | ||
], | ||
"name": "log rules", | ||
"name[zh_CN]": "日志规则", | ||
"description": "log rules", | ||
"description[zh_CN]": "日志规则", | ||
"permissions": "readwrite", | ||
"visibility": "public" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"magic": "dsg.config.meta", | ||
"version": "1.0", | ||
"contents": { | ||
"log_rules": { | ||
"value": "*.debug=false;*.info=false;*.warning=true", | ||
"serial": 0, | ||
"flags": [ | ||
"global" | ||
], | ||
"name": "log rules", | ||
"name[zh_CN]": "日志规则", | ||
"description": "log rules", | ||
"description[zh_CN]": "日志规则", | ||
"permissions": "readwrite", | ||
"visibility": "public" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"magic": "dsg.config.meta", | ||
"version": "1.0", | ||
"contents": { | ||
"log_rules": { | ||
"value": "*.debug=false;*.info=false;*.warning=true", | ||
"serial": 0, | ||
"flags": [ | ||
"global" | ||
], | ||
"name": "log rules", | ||
"name[zh_CN]": "日志规则", | ||
"description": "log rules", | ||
"description[zh_CN]": "日志规则", | ||
"permissions": "readwrite", | ||
"visibility": "public" | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
assets/configs/org.deepin.system-monitor.plugin.popup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"magic": "dsg.config.meta", | ||
"version": "1.0", | ||
"contents": { | ||
"log_rules": { | ||
"value": "*.debug=false;*.info=false;*.warning=true", | ||
"serial": 0, | ||
"flags": [ | ||
"global" | ||
], | ||
"name": "log rules", | ||
"name[zh_CN]": "日志规则", | ||
"description": "log rules", | ||
"description[zh_CN]": "日志规则", | ||
"permissions": "readwrite", | ||
"visibility": "public" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"magic": "dsg.config.meta", | ||
"version": "1.0", | ||
"contents": { | ||
"log_rules": { | ||
"value": "*.debug=false;*.info=false;*.warning=true", | ||
"serial": 0, | ||
"flags": [ | ||
"global" | ||
], | ||
"name": "log rules", | ||
"name[zh_CN]": "日志规则", | ||
"description": "log rules", | ||
"description[zh_CN]": "日志规则", | ||
"permissions": "readwrite", | ||
"visibility": "public" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "deepin-system-monitor", | ||
"group": "", | ||
"submodules": [ | ||
{ | ||
"name": "deepin-system-monitor-daemon", | ||
"filter": "", | ||
"exec": "/usr/lib/x86_64-linux-gnu/deepin-service-manager/libdeepin-system-monitor-daemon.so", | ||
"logType": "journal", | ||
"logPath": "" | ||
}, | ||
{ | ||
"name": "deepin-system-monitor", | ||
"filter": "", | ||
"exec": "/usr/bin/deepin-system-monitor", | ||
"logType": "journal", | ||
"logPath": "" | ||
}, | ||
{ | ||
"name": "deepin-system-monitor-plugin", | ||
"filter": "", | ||
"exec": "/usr/lib/dde-dock/plugins/libdeepin-system-monitor-plugin.so", | ||
"logType": "journal", | ||
"logPath": "" | ||
}, | ||
{ | ||
"name": "deepin-system-monitor-plugin-popup", | ||
"filter": "", | ||
"exec": "/usr/bin/deepin-system-monitor-plugin-popup", | ||
"logType": "journal", | ||
"logPath": "" | ||
}, | ||
{ | ||
"name": "deepin-system-monitor-server", | ||
"filter": "", | ||
"exec": "/usr/bin/deepin-system-monitor-server", | ||
"logType": "journal", | ||
"logPath": "" | ||
} | ||
], | ||
"visible": true, | ||
"version": "V1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd | ||
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#ifndef DDLOG_H | ||
#define DDLOG_H | ||
#include <DConfig> | ||
#include <DLog> | ||
DCORE_USE_NAMESPACE | ||
|
||
namespace DDLog { | ||
inline Q_LOGGING_CATEGORY(app, "org.deepin.system-monitor.daemon") | ||
} | ||
|
||
#endif // DDLOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd | ||
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#include "logger.h" | ||
#include "dtkcore_global.h" | ||
#include "qglobal.h" | ||
#include "ddlog.h" | ||
#include <QLoggingCategory> | ||
#include <QObject> | ||
|
||
#include <DConfig> | ||
using namespace DDLog; | ||
|
||
DCORE_USE_NAMESPACE | ||
|
||
MLogger::MLogger(QObject *parent) | ||
: QObject(parent), m_rules(""), m_config(nullptr) | ||
{ | ||
QByteArray logRules = qgetenv("QT_LOGGING_RULES"); | ||
// qunsetenv 之前一定不要有任何日志打印,否则取消环境变量设置不会生效 | ||
qunsetenv("QT_LOGGING_RULES"); | ||
|
||
// set env | ||
m_rules = logRules; | ||
|
||
// set dconfig | ||
m_config = DConfig::create("org.deepin.system-monitor", "org.deepin.system-monitor.daemon"); | ||
logRules = m_config->value("log_rules").toByteArray(); | ||
appendRules(logRules); | ||
setRules(m_rules); | ||
|
||
// watch dconfig | ||
connect(m_config, &DConfig::valueChanged, this, [this](const QString &key) { | ||
qCritical(app) << "value changed:" << key; | ||
if (key == "log_rules") { | ||
setRules(m_config->value(key).toByteArray()); | ||
} | ||
}); | ||
} | ||
|
||
MLogger::~MLogger() | ||
{ | ||
m_config->deleteLater(); | ||
} | ||
|
||
void MLogger::setRules(const QString &rules) | ||
{ | ||
auto tmpRules = rules; | ||
m_rules = tmpRules.replace(";", "\n"); | ||
QLoggingCategory::setFilterRules(m_rules); | ||
} | ||
|
||
void MLogger::appendRules(const QString &rules) | ||
{ | ||
QString tmpRules = rules; | ||
tmpRules = tmpRules.replace(";", "\n"); | ||
auto tmplist = tmpRules.split('\n'); | ||
for (int i = 0; i < tmplist.count(); i++) | ||
if (m_rules.contains(tmplist.at(i))) { | ||
tmplist.removeAt(i); | ||
i--; | ||
} | ||
if (tmplist.isEmpty()) | ||
return; | ||
m_rules.isEmpty() ? m_rules = tmplist.join("\n") | ||
: m_rules += "\n" + tmplist.join("\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd | ||
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#include <QObject> | ||
#include <dtkcore_global.h> | ||
|
||
DCORE_BEGIN_NAMESPACE | ||
class DConfig; | ||
DCORE_END_NAMESPACE | ||
|
||
class MLogger : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit MLogger(QObject *parent = nullptr); | ||
~MLogger(); | ||
|
||
inline QString rules() const { return m_rules; } | ||
void setRules(const QString &rules); | ||
|
||
private: | ||
void appendRules(const QString &rules); | ||
|
||
private: | ||
QString m_rules; | ||
Dtk::Core::DConfig *m_config; | ||
}; |
Oops, something went wrong.