Skip to content

Commit 1f4316e

Browse files
re2zerodeepin-bot[bot]
authored andcommitted
chore: [log]More logs
Add more logs for log coverage. Log: Add more logs.
1 parent 15c6784 commit 1f4316e

Some content is hidden

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

44 files changed

+1017
-216
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ so(cmake).sh
103103
tests/test_output
104104
translations/*.qm
105105
build
106+
107+
# vscode
108+
.vscode/

src/main.cpp

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ void showWatermark(const QString &sJson, MainWindow *w)
5757
if(mapdata.contains("wndWatermark")) {
5858
mapwaterMark = mapdata.value("wndWatermark").toMap();
5959
}
60-
if(mapwaterMark.isEmpty()) return;
60+
if(mapwaterMark.isEmpty()) {
61+
qDebug() << "no watermark data";
62+
return;
63+
}
6164

6265
#ifdef DTKWIDGET_CLASS_DWaterMarkHelper
6366
auto ins = DWaterMarkHelper::instance();
@@ -117,8 +120,11 @@ void showWatermark(const QString &sJson, MainWindow *w)
117120

118121
int main(int argc, char *argv[])
119122
{
123+
qDebug() << "Application starting with arguments:" << QCoreApplication::arguments();
124+
120125
//for qt5platform-plugins load DPlatformIntegration or DPlatformIntegrationParent
121126
if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) {
127+
qDebug() << "Setting XDG_CURRENT_DESKTOP to Deepin";
122128
setenv("XDG_CURRENT_DESKTOP", "Deepin", 1);
123129
}
124130
bool orderObject = false;
@@ -127,10 +133,11 @@ int main(int argc, char *argv[])
127133

128134
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); // 使用高分屏
129135

130-
// 初始化DTK应用程序属性
136+
qDebug() << "Initializing DTK application properties";
131137
CompressorApplication app(argc, argv);
132138
app.setOrganizationName("deepin");
133139
app.setApplicationName("deepin-compressor");
140+
qDebug() << "Loading application translations";
134141
app.loadTranslator();
135142
app.setApplicationVersion(DApplication::buildVersion(QDate::currentDate().toString("yyyyMMdd")));
136143
app.setApplicationAcknowledgementPage("https://www.deepin.org/original/deepin-compressor/");
@@ -140,8 +147,10 @@ int main(int argc, char *argv[])
140147
app.setApplicationDisplayName(DApplication::translate("Main", "Archive Manager"));
141148
app.setApplicationDescription(DApplication::translate("Main", "Archive Manager is a fast and lightweight application for creating and extracting archives."));
142149
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
150+
qDebug() << "Initializing application settings for Qt5";
143151
DApplicationSettings settings(&app);
144152
#endif
153+
qDebug() << "Setting up logging system";
145154
DLogManager::registerConsoleAppender();
146155
DLogManager::registerFileAppender();
147156

@@ -155,7 +164,7 @@ int main(int argc, char *argv[])
155164
app.setProductIcon(appIcon);
156165
app.setWindowIcon(appIcon);
157166

158-
// 命令行参数的解析
167+
qDebug() << "Initializing command line parser";
159168
QCommandLineParser parser;
160169
parser.setApplicationDescription("Deepin Compressor.");
161170
parser.addHelpOption(); //添加帮助信息(-h,--help),这个方法由QCommandLineParser自动处理
@@ -170,67 +179,83 @@ int main(int argc, char *argv[])
170179
QStringList newfilelist;
171180
if(argc == 3 && QString(argv[2]).startsWith("--param="))
172181
{
182+
qDebug() << "Processing WPS order parameters";
173183
orderObject = true;
174184
QString slast = QString(argv[2]).remove(0,strlen("--param="));
175185
//接收时需要转换为可用数据
176-
qInfo() << "last:" << slast;
186+
qInfo() << "Base64 encoded parameter:" << slast;
177187
sJsonStr = QByteArray::fromBase64(slast.toLatin1().data()).data();
178-
// sJsonStr = sList.last();
179-
qInfo() << "json:" << sJsonStr;
188+
qInfo() << "Decoded JSON parameter:" << sJsonStr;
180189
QString file = argv[1];
181190
if (file.contains("file://")) {
191+
qDebug() << "Removing file:// prefix";
182192
file.remove("file://");
183193
}
184194
newfilelist.append(file);
185195
newfilelist.append(QString(argv[2]));
186196
} else {
197+
qDebug() << "Processing standard command line arguments";
187198
parser.process(app);
188199
foreach (QString file, parser.positionalArguments()) {
189200
if (file.contains("file://")) {
201+
qDebug() << "Removing file:// prefix from:" << file;
190202
file.remove("file://");
191203
}
192204
newfilelist.append(file);
193205
}
194206
}
195207

196-
qInfo() << "传入参数:" << newfilelist;
208+
qInfo() << "Final file list to process:" << newfilelist;
197209
if (orderObject) {
198-
//启动由wps控制,本地不做控制
210+
qDebug() << "Removing WPS parameter from file list";
199211
newfilelist.removeLast();
212+
qDebug() << "WPS order object flag:" << orderObject;
200213
}
201214

202215
// 创建主界面
203216
MainWindow w;
204217
showWatermark(sJsonStr, &w);
205218

206-
// 默认居中显示(使用dbus判断是否为第一个进程,第一个进程居中显示)
219+
qDebug() << "Creating DBus adaptor and connecting to session bus";
207220
ApplicationAdaptor adaptor(&app);
208221
QDBusConnection dbus = QDBusConnection::sessionBus();
222+
209223
if(!orderObject){
224+
qDebug() << "Registering standard DBus service";
210225
if (dbus.registerService("com.deepin.compressor")) {
226+
qDebug() << "DBus service registered successfully, moving window to center";
211227
Dtk::Widget::moveToCenter(&w);
228+
} else {
229+
qWarning() << "Failed to register standard DBus service";
212230
}
213231
} else {
214-
if (dbus.registerService("com.deepin.compressor"+QString::number(QGuiApplication::applicationPid()))) {
215-
dbus.registerObject("/"+QString::number(QGuiApplication::applicationPid()), &app);
216-
adaptor.setCompressFile(newfilelist.first());
217-
Dtk::Widget::moveToCenter(&w);
218-
w.setProperty(ORDER_JSON, sJsonStr);
232+
qDebug() << "Registering WPS-specific DBus service";
233+
QString serviceName = "com.deepin.compressor"+QString::number(QGuiApplication::applicationPid());
234+
if (dbus.registerService(serviceName)) {
235+
qDebug() << "WPS DBus service registered successfully";
236+
QString objectPath = "/"+QString::number(QGuiApplication::applicationPid());
237+
dbus.registerObject(objectPath, &app);
238+
adaptor.setCompressFile(newfilelist.first());
239+
Dtk::Widget::moveToCenter(&w);
240+
w.setProperty(ORDER_JSON, sJsonStr);
241+
qDebug() << "Window properties set for WPS mode";
242+
} else {
243+
qWarning() << "Failed to register WPS DBus service";
219244
}
220-
QDBusConnection dbusConnection = QDBusConnection::sessionBus();
221245

222-
if (dbusConnection.connect("com.wps.cryptfs"
223-
, "/com/wps/cryptfs"
224-
, "cryptfs.method.Type"
225-
, "activateProcess"
226-
, &adaptor
227-
, SLOT(onActiveWindow(qint64))
228-
))
246+
qDebug() << "Connecting to WPS cryptfs DBus interface";
247+
QDBusConnection dbusConnection = QDBusConnection::sessionBus();
248+
if (dbusConnection.connect("com.wps.cryptfs",
249+
"/com/wps/cryptfs",
250+
"cryptfs.method.Type",
251+
"activateProcess",
252+
&adaptor,
253+
SLOT(onActiveWindow(qint64))))
229254
{
230-
qInfo() << "DBus connect success!";
255+
qInfo() << "DBus connection to WPS cryptfs established successfully";
231256
} else {
232-
qInfo() << "DBus connect failed!";
233-
};
257+
qCritical() << "Failed to connect to WPS cryptfs DBus interface";
258+
}
234259
}
235260

236261

src/source/DebugTimeManager.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,63 @@ DebugTimeManager *DebugTimeManager::s_Instance = nullptr;
1313

1414
DebugTimeManager::DebugTimeManager()
1515
{
16-
16+
qDebug() << "DebugTimeManager instance created";
1717
}
1818

1919
void DebugTimeManager::clear()
2020
{
21+
qDebug() << "Clearing all debug points";
2122
m_MapPoint.clear();
23+
qDebug() << "Debug points cleared";
2224
}
2325

2426
void DebugTimeManager::beginPointQt(const QString &point, const QString &status)
2527
{
28+
qDebug() << "Begin Qt debug point:" << point << "status:" << status;
2629
PointInfo info;
2730
info.desc = status;
2831
info.time = QDateTime::currentMSecsSinceEpoch();
2932
m_MapPoint.insert(point, info);
33+
qDebug() << "Qt debug point started";
3034
}
35+
3136
void DebugTimeManager::endPointQt(const QString &point)
3237
{
38+
qDebug() << "End Qt debug point:" << point;
3339
if (m_MapPoint.find(point) != m_MapPoint.end()) {
3440
m_MapPoint[point].time = QDateTime::currentMSecsSinceEpoch() - m_MapPoint[point].time;
3541
qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(m_MapPoint[point].time);
3642
m_MapPoint.remove(point);
43+
qDebug() << "Qt debug point ended successfully";
44+
} else {
45+
qWarning() << "Qt debug point not found:" << point;
3746
}
3847
}
3948

4049
void DebugTimeManager::beginPointLinux(const QString &point, const QString &status)
4150
{
51+
qDebug() << "Begin Linux debug point:" << point << "status:" << status;
4252
struct timeval tv;
4353
gettimeofday(&tv, nullptr);
4454

4555
PointInfo info;
4656
info.desc = status;
4757
info.time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
4858
m_MapPoint.insert(point, info);
59+
qDebug() << "Linux debug point started";
4960
}
61+
5062
void DebugTimeManager::endPointLinux(const QString &point)
5163
{
64+
qDebug() << "End Linux debug point:" << point;
5265
if (m_MapPoint.find(point) != m_MapPoint.end()) {
5366
struct timeval tv;
5467
gettimeofday(&tv, nullptr);
5568
m_MapPoint[point].time = tv.tv_sec * 1000 + tv.tv_usec / 1000 - m_MapPoint[point].time;
5669
qInfo() << QString("[GRABPOINT] %1 %2 time=%3ms").arg(point).arg(m_MapPoint[point].desc).arg(m_MapPoint[point].time);
5770
m_MapPoint.remove(point);
71+
qDebug() << "Linux debug point ended successfully";
72+
} else {
73+
qWarning() << "Linux debug point not found:" << point;
5874
}
5975
}

src/source/archivemanager/archivejob.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
// SPDX-License-Identifier: GPL-3.0-or-later
55

66
#include "archivejob.h"
7+
#include <QDebug>
78

89
ArchiveJob::ArchiveJob(QObject *parent)
910
: QObject(parent)
1011
{
11-
12+
qDebug() << "ArchiveJob object created";
1213
}
1314

1415
ArchiveJob::~ArchiveJob()
1516
{
16-
17+
qDebug() << "ArchiveJob object destroyed";
1718
}
1819

1920
void ArchiveJob::kill()
@@ -22,6 +23,7 @@ void ArchiveJob::kill()
2223
// 设置结束标志
2324
m_eFinishedType = PFT_Cancel;
2425
m_eErrorType = ET_UserCancelOpertion;
26+
qWarning() << "Archive job cancelled by user";
2527
finishJob();
2628
}
2729
}
@@ -33,6 +35,7 @@ bool ArchiveJob::status()
3335

3436
void ArchiveJob::finishJob()
3537
{
38+
qDebug() << "Archive job finished with status:" << m_eFinishedType;
3639
emit signalJobFinshed();
3740
deleteLater();
3841
}

src/source/archivemanager/archivemanager.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ QAtomicPointer<ArchiveManager> ArchiveManager::m_instance = nullptr;//原子指
2424
ArchiveManager::ArchiveManager(QObject *parent)
2525
: QObject(parent)
2626
{
27-
27+
qDebug() << "ArchiveManager instance created";
2828
}
2929

3030
ArchiveManager::~ArchiveManager()
3131
{
32+
qDebug() << "ArchiveManager instance destroyed";
3233
SAFE_DELETE_ELE(m_pArchiveJob);
3334
SAFE_DELETE_ELE(m_pInterface);
3435
SAFE_DELETE_ELE(m_pTempInterface);
@@ -62,12 +63,15 @@ void ArchiveManager::destory_instance()
6263

6364
bool ArchiveManager::createArchive(const QList<FileEntry> &files, const QString &strDestination, const CompressOptions &stOptions, UiTools::AssignPluginType eType)
6465
{
66+
qDebug() << "Starting createArchive operation for destination:" << strDestination;
6567
// 重新创建压缩包首先释放之前的interface
6668
if (m_pInterface != nullptr) {
69+
qDebug() << "Clearing previous archive interface";
6770
delete m_pInterface;
6871
m_pInterface = nullptr;
6972
}
7073
if(DFMStandardPaths::pathControl(strDestination)) {
74+
qWarning() << "Path control check failed for destination:" << strDestination;
7175
return false;
7276
}
7377
m_pTempInterface = UiTools::createInterface(strDestination, true, eType);
@@ -83,14 +87,17 @@ bool ArchiveManager::createArchive(const QList<FileEntry> &files, const QString
8387
m_pArchiveJob = pCreateJob;
8488
pCreateJob->start();
8589

90+
qInfo() << "CreateArchive operation started successfully";
8691
return true;
8792
}
8893

94+
qWarning() << "Failed to create archive interface";
8995
return false;
9096
}
9197

9298
bool ArchiveManager::loadArchive(const QString &strArchiveFullPath, UiTools::AssignPluginType eType)
9399
{
100+
qDebug() << "Starting loadArchive operation for file:" << strArchiveFullPath;
94101
QJsonObject obj{
95102
{"tid", EventLogUtils::LoadCompressFile},
96103
{"operate", "LoadCompressFile"},
@@ -99,6 +106,7 @@ bool ArchiveManager::loadArchive(const QString &strArchiveFullPath, UiTools::Ass
99106
EventLogUtils::get().writeLogs(obj);
100107
// 重新加载首先释放之前的interface
101108
if (m_pInterface != nullptr) {
109+
qDebug() << "Clearing previous archive interface";
102110
delete m_pInterface;
103111
m_pInterface = nullptr;
104112
}
@@ -115,9 +123,11 @@ bool ArchiveManager::loadArchive(const QString &strArchiveFullPath, UiTools::Ass
115123
m_pArchiveJob = pLoadJob;
116124
pLoadJob->start();
117125

126+
qInfo() << "LoadArchive operation started successfully";
118127
return true;
119128
}
120129

130+
qWarning() << "Failed to load archive interface";
121131
return false;
122132
}
123133

@@ -456,6 +466,10 @@ void ArchiveManager::slotJobFinished()
456466
PluginFinishType eFinishType = m_pArchiveJob->m_eFinishedType;
457467
ErrorType eErrorType = m_pArchiveJob->m_eErrorType;
458468

469+
qInfo() << "Job finished - Type:" << eJobType
470+
<< "FinishType:" << eFinishType
471+
<< "ErrorType:" << eErrorType;
472+
459473
// 释放job
460474
m_pArchiveJob->deleteLater();
461475
m_pArchiveJob = nullptr;
@@ -466,4 +480,5 @@ void ArchiveManager::slotJobFinished()
466480

467481
// 释放临时记录的interface
468482
SAFE_DELETE_ELE(m_pTempInterface);
483+
qDebug() << "Temporary interface cleared";
469484
}

0 commit comments

Comments
 (0)