-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
2,018 additions
and
1,252 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
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,11 @@ | ||
#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,64 @@ | ||
#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,23 @@ | ||
#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; | ||
}; |
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
Oops, something went wrong.