Skip to content

Commit 94b3d2b

Browse files
lJxDababdeepin-bot[bot]
authored andcommitted
fix: Device Manager log optimization
modify q-level to qC-level and add log monitor to push Device Manager log optimization Log: modify q-level to qC-level and add log monitor to push Device Manager log optimization Bug: https://pms.uniontech.com/task-view-342033.html (cherry picked from commit d79573d)
1 parent 2358a5e commit 94b3d2b

127 files changed

Lines changed: 541 additions & 340 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.reuse/dep5

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,4 @@ License: GPL-3.0-or-later
6666
# 3rdparty/QtXlsxWriter
6767
Files: deepin-devicemanager/3rdparty/QtXlsxWriter/*
6868
Copyright: 2013-2014 Debao Zhang <hello@debao.me>
69-
License: MIT
70-
69+
License: MIT

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ add_subdirectory(${CMAKE_SOURCE_DIR}/deepin-devicemanager-server)
2222
if(CMAKE_COVERAGE_ARG STREQUAL "CMAKE_COVERAGE_ARG_ON")
2323
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -fprofile-arcs -ftest-coverage")
2424
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -fprofile-arcs -ftest-coverage")
25-
endif()
25+
endif()

deepin-devicemanager-server/deepin-devicecontrol/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ MACRO(SUBDIRLIST result curdir)
2222
SET(${result} ${dirlist})
2323
ENDMACRO()
2424
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
25+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../deepin-devicemanager/src/DDLog)
2526
SUBDIRLIST(dirs ${CMAKE_CURRENT_SOURCE_DIR}/src)
2627
foreach(dir ${dirs})
2728
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/${dir})
@@ -80,4 +81,4 @@ install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
8081
install(FILES ${BIN_NAME}.json DESTINATION share/deepin-service-manager/other/)
8182
install(FILES org.deepin.devicecontrol.conf DESTINATION share/dbus-1/system.d/)
8283
install(FILES org.deepin.DeviceControl.service DESTINATION share/dbus-1/system-services/)
83-
install(FILES deepin-devicecontrol.service DESTINATION lib/systemd/system/)
84+
install(FILES deepin-devicecontrol.service DESTINATION lib/systemd/system/)

deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
#include "enablesqlmanager.h"
1111
#include "enableutils.h"
1212
#include "wakeuputils.h"
13+
#include "DDLog.h"
1314

14-
#include <QDebug>
15+
#include <QLoggingCategory>
1516
#include <QProcess>
1617
#include <QDir>
1718
#include <QDBusConnection>
@@ -25,7 +26,7 @@
2526
#include <string>
2627

2728
using namespace PolkitQt1;
28-
29+
using namespace DDLog;
2930
static int getPidByName(const QString &taskName)
3031
{
3132
DIR *dir = opendir("/proc");
@@ -418,7 +419,7 @@ bool ControlInterface::removeEnable(const QString &hclass, const QString &name,
418419
// 1. 直接remove写入
419420
// 通过remove文件禁用
420421
// 1:表示禁用 ,0:表示启用
421-
qInfo() << "" << "/sys" + path + QString("/remove");
422+
qCInfo(appLog) << "" << "/sys" + path + QString("/remove");
422423
// return false;
423424
QFile file("/sys" + path + QString("/remove"));
424425
if (!file.open(QIODevice::WriteOnly)) {

deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/debinstaller.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66

77
#include "debinstaller.h"
88
#include "utils.h"
9+
#include "DDLog.h"
910

10-
#include <QDebug>
11+
#include <QLoggingCategory>
1112
#include <QTimer>
1213

1314
#include <QApt/Backend>
1415
#include <QApt/DebFile>
1516
#include <QApt/Transaction>
1617

18+
using namespace DDLog;
19+
1720
const int MAX_DPKGRUNING_TEST = 20;
1821
const int TEST_TIME_INTERVAL = 2000;
1922

@@ -55,15 +58,15 @@ void DebInstaller::initBackend()
5558
m_backend = new QApt::Backend;
5659
m_bValid = m_backend->init();
5760
if (!m_bValid) {
58-
qInfo() << m_backend->initErrorMessage();
61+
qCInfo(appLog) << m_backend->initErrorMessage();
5962
}
6063
}
6164

6265
void DebInstaller::reset()
6366
{
6467
m_bValid = m_backend->reloadCache();
6568
if (!m_bValid) {
66-
qInfo() << m_backend->initErrorMessage();
69+
qCInfo(appLog) << m_backend->initErrorMessage();
6770
}
6871
m_iRuningTestCount = 0;
6972
m_pTrans = nullptr;

deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/driverinstaller.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
#include "driverinstaller.h"
88
#include "utils.h"
99
#include "commonfunction.h"
10+
#include "DDLog.h"
1011

1112
#include <QApt/Backend>
1213
#include <QApt/DebFile>
1314
#include <QApt/Transaction>
14-
#include <QDebug>
15+
#include <QLoggingCategory>
1516
#include <QProcess>
1617
#include <QTimer>
1718

@@ -20,6 +21,7 @@
2021
#include <string>
2122
#include <vector>
2223

24+
using namespace DDLog;
2325
const int MAX_DPKGRUNING_TEST = 20;
2426
const int TEST_TIME_INTERVAL = 2000;
2527

@@ -69,7 +71,7 @@ void DriverInstaller::undoInstallDriver()
6971
mp_Trans->setProperty("isCancelled", true);
7072
mp_Trans->cancel();
7173
m_Cancel = true;
72-
qInfo() << "DRIVER_LOG **************************** 取消操作";
74+
qCInfo(appLog) << "DRIVER_LOG **************************** 取消操作";
7375
}
7476

7577
}
@@ -126,21 +128,21 @@ void DriverInstaller::doOperate(const QString &package, const QString &version)
126128
{
127129
if (!initBackend()) {
128130
emit errorOccurred(EC_NULL);
129-
qInfo() << "DRIVER_LOG : ************************** 初始化backend失败";
131+
qCInfo(appLog) << "DRIVER_LOG : ************************** 初始化backend失败";
130132
return;
131133
}
132134

133135
QApt::Package *p = mp_Backend->package(package);
134136
// 判断包是否存在
135137
if (nullptr == p) {
136138
emit errorOccurred(EC_NOTFOUND);
137-
qInfo() << "DRIVER_LOG : ************************** 安装包不存在";
139+
qCInfo(appLog) << "DRIVER_LOG : ************************** 安装包不存在";
138140
return;
139141
}
140142

141143
// 版本不存在
142144
if (!p->setVersion(version)) {
143-
qInfo() << "DRIVER_LOG : ************************** 安装包版本不存在";
145+
qCInfo(appLog) << "DRIVER_LOG : ************************** 安装包版本不存在";
144146
emit errorOccurred(EC_NOTFOUND);
145147
delete p;
146148
p = nullptr;
@@ -153,7 +155,7 @@ void DriverInstaller::doOperate(const QString &package, const QString &version)
153155
mp_Trans = mp_Backend->installPackages(lst);
154156
if (nullptr == mp_Trans) {
155157
emit errorOccurred(EC_NULL);
156-
qInfo() << "DRIVER_LOG : ************************** installPackages";
158+
qCInfo(appLog) << "DRIVER_LOG : ************************** installPackages";
157159
return;
158160
}
159161

@@ -179,21 +181,21 @@ void DriverInstaller::doOperate(const QString &package, const QString &version)
179181
emit errorOccurred(EC_CANCEL);
180182
}
181183

182-
qInfo() << "DRIVER_LOG : ************************** 安装结束 结束状态码" << status;
183-
qInfo() << "DRIVER_LOG : ************************** 安装结束 结束错误码" << code;
184+
qCInfo(appLog) << "DRIVER_LOG : ************************** 安装结束 结束状态码" << status;
185+
qCInfo(appLog) << "DRIVER_LOG : ************************** 安装结束 结束错误码" << code;
184186

185187
mp_Trans->disconnect();
186188
mp_Trans->deleteLater();
187189
mp_Trans = nullptr;
188190
});
189191

190192
connect(mp_Trans, &QApt::Transaction::downloadProgressChanged, this, [this](QApt::DownloadProgress dp) {
191-
qInfo() << "DRIVER_LOG : ************************** 下载进度 " << dp.progress();
193+
qCInfo(appLog) << "DRIVER_LOG : ************************** 下载进度 " << dp.progress();
192194
if (m_Cancel) {
193195
mp_Trans->setProperty("isCancellable", true);
194196
mp_Trans->setProperty("isCancelled", true);
195197
mp_Trans->cancel();
196-
qInfo() << "DRIVER_LOG *************downloadProgressChanged*************** 取消操作";
198+
qCInfo(appLog) << "DRIVER_LOG *************downloadProgressChanged*************** 取消操作";
197199
}
198200
});
199201

@@ -202,11 +204,11 @@ void DriverInstaller::doOperate(const QString &package, const QString &version)
202204
mp_Trans->setProperty("isCancellable", true);
203205
mp_Trans->setProperty("isCancelled", true);
204206
mp_Trans->cancel();
205-
qInfo() << "DRIVER_LOG *************progressChanged*************** 取消操作";
207+
qCInfo(appLog) << "DRIVER_LOG *************progressChanged*************** 取消操作";
206208
}
207209
if (false == m_Cancel)
208210
emit installProgressChanged(progress);
209-
qInfo() << "DRIVER_LOG : ************************** 总进度 " << progress << " 下载状态 " << mp_Trans->downloadProgress().uri();
211+
qCInfo(appLog) << "DRIVER_LOG : ************************** 总进度 " << progress << " 下载状态 " << mp_Trans->downloadProgress().uri();
210212
});
211213

212214
mp_Trans->run();

deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/drivermanager.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
#include "driverinstaller.h"
1212
//#include "DeviceInfoManager.h"
1313
#include "httpdriverinterface.h"
14+
#include "DDLog.h"
1415

1516
#include <QThread>
1617
#include <QFile>
1718
#include <QMimeDatabase>
1819
#include <QMimeType>
1920
#include <QDir>
2021
#include <QFileInfo>
21-
#include <QDebug>
22+
#include <QLoggingCategory>
2223
#include <QPair>
2324
#include <QJsonObject>
2425
#include <QNetworkAccessManager>
@@ -34,7 +35,7 @@
3435
#include <QNetworkConfigurationManager>
3536
#include <QDir>
3637
#include <QFileInfoList>
37-
#include <QDebug>
38+
#include <QLoggingCategory>
3839

3940
#include <fstream>
4041
#include <string>
@@ -63,6 +64,7 @@
6364
sigFinished(flag, errmsg);\
6465
return flag; \
6566
}
67+
using namespace DDLog;
6668

6769
DriverManager::DriverManager(QObject *parent)
6870
: QObject(parent)
@@ -105,7 +107,7 @@ void DriverManager::initConnections()
105107
sigProgressDetail(m_installprocess, errmsg);
106108
});
107109
connect(mp_debinstaller, &DebInstaller::errorOccurred, [&](QString errmsg) {
108-
qInfo() << "signal_installFailedReason:" << errmsg;
110+
qCInfo(appLog) << "signal_installFailedReason:" << errmsg;
109111
sigFinished(false, errmsg);
110112
this->errmsg = errmsg;
111113
});
@@ -115,23 +117,23 @@ void DriverManager::initConnections()
115117
connect(mp_driverInstaller, &DriverInstaller::installProgressFinished, [&](bool bsuccess) {
116118
if (bsuccess) {
117119
sigInstallProgressFinished(bsuccess, EC_NULL);
118-
qInfo() << "Driver installed successfully";
120+
qCInfo(appLog) << "Driver installed successfully";
119121
} else {
120-
qInfo() << "Driver installation failed , reason : unknow";
122+
qCInfo(appLog) << "Driver installation failed , reason : unknow";
121123
}
122124
});
123125

124126
connect(mp_driverInstaller, &DriverInstaller::errorOccurred, [this](int err) {
125127
if (EC_NETWORK != err) {
126-
qInfo() << "Driver installation failed , reason : " << err;
128+
qCInfo(appLog) << "Driver installation failed , reason : " << err;
127129
sigInstallProgressFinished(false, err);
128130
return;
129131
}
130132

131133
// 如果错误是网络异常,则需要尝试60s
132134
// 先通知前台网络异常
133135
sigInstallProgressFinished(false, EC_NOTIFY_NETWORK);
134-
qInfo() << "Network error : We are listening to the network";
136+
qCInfo(appLog) << "Network error : We are listening to the network";
135137

136138
// 60s等待操作
137139
m_IsNetworkOnline = false;
@@ -157,7 +159,7 @@ void DriverManager::initConnections()
157159

158160
connect(mp_driverInstaller, &DriverInstaller::installProgressChanged, [&](int progress) {
159161
sigInstallProgressChanged(progress);
160-
qInfo() << "Installing driver , installation progress : " << progress;
162+
qCInfo(appLog) << "Installing driver , installation progress : " << progress;
161163
});
162164
}
163165

@@ -239,7 +241,7 @@ bool DriverManager::installDriver(const QString &filepath)
239241
QMimeDatabase typedb;
240242
QMimeType filetype = typedb.mimeTypeForFile(fileinfo);
241243
if (filetype.filterString().contains("deb")) {
242-
qInfo() << __func__ << "deb install start";
244+
qCInfo(appLog) << __func__ << "deb install start";
243245
sigProgressDetail(15, "");
244246
emit sigDebInstall(filepath);
245247
sigProgressDetail(20, "");
@@ -645,13 +647,13 @@ static bool qdelDirectory(QString toDir)
645647

646648
//拷贝子目录
647649
if (fileInfo.isDir()) {
648-
qInfo() << "del isDir";
650+
qCInfo(appLog) << "del isDir";
649651
//递归调用拷贝
650652
if (!qdelDirectory(toDir_.filePath(fileInfo.fileName())))
651653
return false;
652654
} else {
653655
toDir_.remove(fileInfo.fileName());
654-
qInfo() << "del remove";
656+
qCInfo(appLog) << "del remove";
655657
}
656658
}
657659
return true;
@@ -704,7 +706,7 @@ bool DriverManager::delDeb(const QString &debname)
704706
QString backupPath = QString("%1/driver/%2").arg(DB_PATH).arg(debname);
705707
QDir destdir(backupPath);
706708
if (destdir.exists()) {
707-
qInfo() << "delDeb" << backupPath << destdir.absolutePath();
709+
qCInfo(appLog) << "delDeb" << backupPath << destdir.absolutePath();
708710
qdelDirectory(backupPath);
709711
destdir.rmdir(destdir.absolutePath());
710712
}
@@ -718,7 +720,7 @@ bool DriverManager::aptUpdate()
718720
QByteArray outArry = process.readAllStandardOutput();
719721
QList<QString> lines = QString(outArry).split('\n', QString::SkipEmptyParts);
720722
for (const QString &line : qAsConst(lines)) {
721-
// qDebug() << line;
723+
// qCDebug() << line;
722724
// error handling...
723725
}
724726
}); */
@@ -737,7 +739,7 @@ bool DriverManager::backupDeb(const QString &debpath)
737739
{
738740
QDir formDir_(debpath);
739741
if (!formDir_.exists()) { //检查传入路径是否存在
740-
qInfo() << "no bank up file";
742+
qCInfo(appLog) << "no bank up file";
741743
return false;
742744
}
743745

@@ -758,7 +760,7 @@ bool DriverManager::backupDeb(const QString &debpath)
758760
return false;
759761
}
760762
}
761-
qInfo() << "copy file" << fromPath << backupPath << debname;
763+
qCInfo(appLog) << "copy file" << fromPath << backupPath << debname;
762764
return qCopyDirectory(fromPath, backupPath, true);
763765
}
764766

deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/httpdriverinterface.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "httpdriverinterface.h"
66
#include "commonfunction.h"
77
#include "utils.h"
8+
#include "DDLog.h"
89

910
#include <QJsonDocument>
1011
#include <QtNetwork>
@@ -13,6 +14,7 @@
1314

1415
#include <DSysInfo>
1516

17+
using namespace DDLog;
1618
// 以下这个问题可以避免单例的内存泄露问题
1719
std::atomic<HttpDriverInterface *> HttpDriverInterface::s_Instance;
1820
std::mutex HttpDriverInterface::m_mutex;
@@ -96,7 +98,7 @@ QString HttpDriverInterface::getRequestBoard(QString strManufacturer, QString st
9698
if (0 < iClass) {
9799
strUrl += "&class=" + QString(iClass);
98100
}
99-
qInfo() << strUrl;
101+
qCInfo(appLog) << strUrl;
100102
return getRequestJson(strUrl);
101103
}
102104

@@ -168,15 +170,15 @@ bool HttpDriverInterface::checkDriverInfo(QString strJson, DriverInfo &driverInf
168170
}
169171
}
170172
}
171-
qInfo() << "packages: " << driverInfo.packages;
172-
qInfo() << "debVersion: " << driverInfo.debVersion;
173-
qInfo() << "driverName: " << driverInfo.driverName;
174-
qInfo() << "version: " << driverInfo.version;
173+
qCInfo(appLog) << "packages: " << driverInfo.packages;
174+
qCInfo(appLog) << "debVersion: " << driverInfo.debVersion;
175+
qCInfo(appLog) << "driverName: " << driverInfo.driverName;
176+
qCInfo(appLog) << "version: " << driverInfo.version;
175177

176-
qInfo() << lstDriverInfo.size();
178+
qCInfo(appLog) << lstDriverInfo.size();
177179
foreach (const RepoDriverInfo &di, lstDriverInfo) {
178-
qInfo() << "strPackages: " << di.strPackages;
179-
qInfo() << "strDebVersion: " << di.strDebVersion;
180+
qCInfo(appLog) << "strPackages: " << di.strPackages;
181+
qCInfo(appLog) << "strDebVersion: " << di.strDebVersion;
180182
}
181183
return true;
182184
}

deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/httpdriverinterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "commonfunction.h"
88

99
#include <QObject>
10-
#include <QDebug>
10+
#include <QLoggingCategory>
1111
#include <QNetworkAccessManager>
1212
#include <QUrl>
1313

0 commit comments

Comments
 (0)