Skip to content

Commit ac0b197

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

46 files changed

Lines changed: 552 additions & 35 deletions

Some content is hidden

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

src/common/eventlogutils.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
#include <QDir>
88
#include <QLibraryInfo>
99
#include <QJsonDocument>
10+
#include <QDebug>
1011

1112
#include "eventlogutils.h"
1213

1314
EventLogUtils *EventLogUtils::mInstance(nullptr);
1415

1516
EventLogUtils &EventLogUtils::get()
1617
{
18+
qDebug() << "Enter EventLogUtils::get()";
1719
if (mInstance == nullptr) {
1820
mInstance = new EventLogUtils;
1921
}
22+
qDebug() << "Exit EventLogUtils::get()";
2023
return *mInstance;
2124
}
2225

@@ -27,17 +30,23 @@ EventLogUtils::EventLogUtils()
2730
init =reinterpret_cast<bool (*)(const std::string &, bool)>(library.resolve("Initialize"));
2831
writeEventLog = reinterpret_cast<void (*)(const std::string &)>(library.resolve("WriteEventLog"));
2932

30-
if (init == nullptr)
33+
if (init == nullptr) {
34+
qWarning() << "Failed to resolve Initialize function in libdeepin-event-log.so";
3135
return;
36+
}
3237

3338
init("deepin-terminal", true);
3439
}
3540

3641
void EventLogUtils::writeLogs(QJsonObject &data)
3742
{
38-
if (writeEventLog == nullptr)
43+
qDebug() << "Enter EventLogUtils::writeLogs()";
44+
if (writeEventLog == nullptr) {
45+
qWarning() << "writeEventLog function pointer is null";
3946
return;
47+
}
4048

4149
//std::string str = QJsonDocument(data).toJson(QJsonDocument::Compact).toStdString();
4250
writeEventLog(QJsonDocument(data).toJson(QJsonDocument::Compact).toStdString());
51+
qDebug() << "Exit EventLogUtils::writeLogs()";
4352
}

src/common/settingio.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
bool SettingIO::rewrite = false;
1616
SettingIO::SettingIO(QObject *parent) : QObject(parent)
1717
{
18-
18+
qDebug() << "SettingIO constructor";
1919
}
2020

2121
bool SettingIO::readIniFunc(QIODevice &device, QSettings::SettingsMap &settingsMap)
2222
{
23+
qDebug() << "Enter SettingIO::readIniFunc";
2324
QString currentSection;
2425
QTextStream stream(&device);
2526
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
@@ -112,11 +113,13 @@ bool SettingIO::readIniFunc(QIODevice &device, QSettings::SettingsMap &settingsM
112113
}
113114
}
114115
}
116+
qDebug() << "Exit SettingIO::readIniFunc";
115117
return true;
116118
}
117119

118120
bool SettingIO::writeIniFunc(QIODevice &device, const QSettings::SettingsMap &settingsMap)
119121
{
122+
qDebug() << "Enter SettingIO::writeIniFunc";
120123
#ifdef Q_OS_WIN
121124
const char *const eol = "\r\n";
122125
#else
@@ -179,6 +182,7 @@ bool SettingIO::writeIniFunc(QIODevice &device, const QSettings::SettingsMap &se
179182
if (device.write(block) == -1)
180183
writeError = true;
181184
}
185+
qDebug() << "Exit SettingIO::writeIniFunc";
182186
return true;
183187
}
184188

@@ -490,7 +494,10 @@ USettings::USettings(const QString &fileName, QObject *parent)
490494
}
491495

492496
//析构函数
493-
USettings::~USettings() {}
497+
USettings::~USettings()
498+
{
499+
qDebug() << "USettings destructor";
500+
}
494501

495502
void USettings::beginGroup(const QString &prefix)
496503
{

src/common/utils.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,26 @@ Q_LOGGING_CATEGORY(common,"org.deepin.terminal.common",QtInfoMsg)
5858

5959
QString Utils::getQssContent(const QString &filePath)
6060
{
61+
qCDebug(common) << "Reading QSS content from:" << filePath;
6162
QFile file(filePath);
6263
QString qss;
6364

64-
if (file.open(QIODevice::ReadOnly))
65+
if (file.open(QIODevice::ReadOnly)) {
6566
qss = file.readAll();
67+
qCDebug(common) << "Successfully read" << qss.size() << "bytes from QSS file";
68+
} else {
69+
qCWarning(common) << "Failed to open QSS file:" << filePath << "Error:" << file.errorString();
70+
}
6671

6772
return qss;
6873
}
6974

7075
QString Utils::getConfigPath()
7176
{
77+
qCDebug(common) << "Getting config path";
7278
static QStringList list = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
7379
const QString path = list.value(0);
80+
qCDebug(common) << "Config path:" << path;
7481
QDir dir(
7582
QDir(path).filePath(qApp->organizationName()));
7683

@@ -122,7 +129,9 @@ QString Utils::getRandString()
122129

123130
QString Utils::showDirDialog(QWidget *widget)
124131
{
132+
qCDebug(common) << "Showing directory dialog";
125133
QString curPath = QDir::currentPath();
134+
qCDebug(common) << "Current path:" << curPath;
126135
QString dlgTitle = QObject::tr("Select a directory to save the file");
127136

128137
DFileDialog dialog(widget, dlgTitle, curPath);
@@ -135,15 +144,19 @@ QString Utils::showDirDialog(QWidget *widget)
135144
if (QDialog::Accepted == code && !dialog.selectedFiles().isEmpty()) {
136145
QStringList list = dialog.selectedFiles();
137146
const QString dirName = list.value(0);
147+
qCDebug(common) << "Selected directory:" << dirName;
138148
return dirName;
139149
} else {
150+
qCDebug(common) << "Directory selection canceled";
140151
return "";
141152
}
142153
}
143154

144155
QStringList Utils::showFilesSelectDialog(QWidget *widget)
145156
{
157+
qCDebug(common) << "Showing file selection dialog";
146158
QString curPath = QDir::currentPath();
159+
qCDebug(common) << "Current path:" << curPath;
147160
QString dlgTitle = QObject::tr("Select file to upload");
148161

149162
DFileDialog dialog(widget, dlgTitle, curPath);
@@ -156,6 +169,7 @@ QStringList Utils::showFilesSelectDialog(QWidget *widget)
156169
if (code == QDialog::Accepted)
157170
return dialog.selectedFiles();
158171

172+
qCDebug(common) << "File selection canceled";
159173
return QStringList();
160174
}
161175

src/customcommand/customcommandoptdlg.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ CustomCommandOptDlg::CustomCommandOptDlg(CustomCmdOptType type, CustomCommandDat
4141
, m_shortCutLineEdit(new DKeySequenceEdit(this))
4242
, m_bDelOpt(false)
4343
{
44+
qCDebug(customcommand) << "Creating CustomCommandOptDlg, type:" << type;
4445
/******** Add by ut001000 renfeixiang 2020-08-13:增加 Begin***************/
4546
Utils::set_Object_Name(this);
4647
m_nameLineEdit->setObjectName("CustomNameLineEdit");
@@ -62,6 +63,7 @@ CustomCommandOptDlg::CustomCommandOptDlg(CustomCmdOptType type, CustomCommandDat
6263

6364
CustomCommandOptDlg::~CustomCommandOptDlg()
6465
{
66+
qCDebug(customcommand) << "Destroying CustomCommandOptDlg";
6567
if (m_currItemData) {
6668
delete m_currItemData;
6769
m_currItemData = nullptr;
@@ -74,6 +76,7 @@ CustomCommandOptDlg::~CustomCommandOptDlg()
7476

7577
void CustomCommandOptDlg::initUI()
7678
{
79+
qCDebug(customcommand) << "Initializing CustomCommandOptDlg UI";
7780
QWidget *contentFrame = new QWidget(this);
7881

7982
QVBoxLayout *contentLayout = new QVBoxLayout;
@@ -140,6 +143,7 @@ void CustomCommandOptDlg::initUI()
140143
addContent(contentFrame);
141144
//判断是添加操作窗口还是修改操作窗口
142145
if (CCT_ADD == m_type) {
146+
qCInfo(customcommand) << "Setting up Add Command dialog";
143147
setTitle(tr("Add Command"));
144148
initCommandFromClipBoardText();
145149

@@ -149,6 +153,7 @@ void CustomCommandOptDlg::initUI()
149153
getMainLayout()->addSpacing(m_iSpaceSizeEighteen);
150154
#endif
151155
} else {
156+
qCInfo(customcommand) << "Setting up Edit Command dialog";
152157
setTitle(tr("Edit Command"));
153158

154159
m_deleteCmdWidget = new QWidget(this);
@@ -354,10 +359,12 @@ inline void CustomCommandOptDlg::slotThemeTypeChanged(DGuiApplicationHelper::Col
354359

355360
void CustomCommandOptDlg::initCommandFromClipBoardText()
356361
{
362+
qCDebug(customcommand) << "Initializing command from clipboard";
357363
if (m_commandLineEdit) {
358364
MainWindow *main = Utils::getMainWindow(this);//;getMainWindow();
359365
if (main != nullptr) {
360366
QString clipText = main->selectedText();
367+
qCDebug(customcommand) << "Clipboard text:" << clipText;
361368
m_commandLineEdit->setText(clipText.trimmed());
362369
}
363370
}
@@ -489,6 +496,7 @@ void CustomCommandOptDlg::setModelIndex(const QModelIndex &mi)
489496

490497
void CustomCommandOptDlg::slotDelCurCustomCommand()
491498
{
499+
qCInfo(customcommand) << "Deleting current custom command";
492500
m_bDelOpt = true;
493501
reject();
494502
}

src/customcommand/customcommandpanel.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ Q_DECLARE_LOGGING_CATEGORY(customcommand)
2323

2424
CustomCommandPanel::CustomCommandPanel(QWidget *parent) : CommonPanel(parent)
2525
{
26+
qCDebug(customcommand) << "Creating CustomCommandPanel";
2627
Utils::set_Object_Name(this);
2728
initUI();
2829
}
2930
CustomCommandPanel::~CustomCommandPanel()
3031
{
32+
qCDebug(customcommand) << "Destroying CustomCommandPanel";
3133
if (m_pdlg) {
3234
delete m_pdlg;
3335
m_pdlg = nullptr;
@@ -36,10 +38,14 @@ CustomCommandPanel::~CustomCommandPanel()
3638

3739
void CustomCommandPanel::showCurSearchResult()
3840
{
41+
qCDebug(customcommand) << "Showing search results";
3942
QString strTxt = m_searchEdit->text();
40-
if (strTxt.isEmpty())
43+
if (strTxt.isEmpty()) {
44+
qCDebug(customcommand) << "Search text is empty";
4145
return;
46+
}
4247

48+
qCInfo(customcommand) << "Searching for:" << strTxt;
4349
emit showSearchResult(strTxt);
4450
}
4551

@@ -69,14 +75,20 @@ void CustomCommandPanel::showAddCustomCommandDlg()
6975

7076
void CustomCommandPanel::doCustomCommand(const QString &key)
7177
{
78+
qCDebug(customcommand) << "Executing custom command with key:" << key;
7279
QAction *item = ShortcutManager::instance()->findActionByKey(key);
73-
if(!item)
80+
if(!item) {
81+
qCWarning(customcommand) << "No command found for key:" << key;
7482
return;
83+
}
7584

7685
QString strCommand = item->data().toString();
77-
if (!strCommand.endsWith('\n'))
86+
if (!strCommand.endsWith('\n')) {
87+
qCDebug(customcommand) << "Appending newline to command";
7888
strCommand.append('\n');
89+
}
7990

91+
qCInfo(customcommand) << "Executing command:" << strCommand;
8092
emit handleCustomCurCommand(strCommand);
8193
}
8294

@@ -125,8 +137,10 @@ void CustomCommandPanel::onAddCommandResponse(int result)
125137

126138
void CustomCommandPanel::refreshCmdPanel()
127139
{
140+
qCDebug(customcommand) << "Refreshing command panel";
128141
clearSearchInfo();
129142
ShortcutManager::instance()->fillCommandListData(m_cmdListWidget);
143+
qCDebug(customcommand) << "Command list updated, count:" << m_cmdListWidget->count();
130144
refreshCmdSearchState();
131145
}
132146

@@ -179,6 +193,7 @@ void CustomCommandPanel::setFocusInPanel()
179193

180194
void CustomCommandPanel::initUI()
181195
{
196+
qCDebug(customcommand) << "Initializing CustomCommandPanel UI";
182197
setBackgroundRole(QPalette::Base);
183198
setAutoFillBackground(true);
184199

src/customcommand/customcommandplugin.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,22 @@ Q_DECLARE_LOGGING_CATEGORY(customcommand)
1919

2020
CustomCommandPlugin::CustomCommandPlugin(QObject *parent) : MainWindowPluginInterface(parent)
2121
{
22+
qCDebug(customcommand) << "Creating CustomCommandPlugin";
2223
Utils::set_Object_Name(this);
2324
m_pluginName = "Custom Command";
25+
qCDebug(customcommand) << "Plugin name set to:" << m_pluginName;
2426
}
2527

2628
void CustomCommandPlugin::initPlugin(MainWindow *mainWindow)
2729
{
30+
qCDebug(customcommand) << "Initializing CustomCommandPlugin";
2831
m_mainWindow = mainWindow;
2932
connect(m_mainWindow, &MainWindow::showPluginChanged, this, &CustomCommandPlugin::doShowPlugin);
3033
connect(m_mainWindow, &MainWindow::quakeHidePlugin, this, [ = ]() {
34+
qCDebug(customcommand) << "Hiding command panel in quake mode";
3135
getCustomCommandTopPanel()->hide();
3236
});
37+
qCDebug(customcommand) << "Plugin initialization complete";
3338
}
3439

3540
QAction *CustomCommandPlugin::titlebarMenu(MainWindow *mainWindow)
@@ -45,12 +50,14 @@ QAction *CustomCommandPlugin::titlebarMenu(MainWindow *mainWindow)
4550

4651
void CustomCommandPlugin::initCustomCommandTopPanel()
4752
{
53+
qCDebug(customcommand) << "Initializing custom command top panel";
4854
m_customCommandTopPanel = new CustomCommandTopPanel(m_mainWindow->centralWidget());
4955
m_customCommandTopPanel->setObjectName("CustomCustomCommandTopPanel");//Add by ut001000 renfeixiang 2020-08-14
5056
connect(m_customCommandTopPanel,
5157
&CustomCommandTopPanel::handleCustomCurCommand,
5258
this,
5359
&CustomCommandPlugin::doCustomCommand);
60+
qCDebug(customcommand) << "Custom command top panel initialized";
5461
}
5562

5663
CustomCommandTopPanel *CustomCommandPlugin::getCustomCommandTopPanel()
@@ -63,40 +70,50 @@ CustomCommandTopPanel *CustomCommandPlugin::getCustomCommandTopPanel()
6370

6471
void CustomCommandPlugin::doCustomCommand(const QString &strTxt)
6572
{
73+
qCDebug(customcommand) << "Executing custom command:" << strTxt;
6674
if (!strTxt.isEmpty()) {
75+
qCInfo(customcommand) << "Sending command to terminal:" << strTxt;
6776
m_mainWindow->currentPage()->sendTextToCurrentTerm(strTxt);
6877
m_mainWindow->focusCurrentPage();
6978
/******** Add by nt001000 renfeixiang 2020-05-28:增加 使用mainwindow的hideplugin函数隐藏自定义窗口bug#21992 Begin***************/
79+
qCDebug(customcommand) << "Hiding plugin after command execution";
7080
m_mainWindow->showPlugin(MainWindow::PLUGIN_TYPE_NONE);
7181
/******** Add by nt001000 renfeixiang 2020-05-28:增加 使用mainwindow的hideplugin函数隐藏自定义窗口bug#21992 End***************/
7282
}
7383
emit doHide();
84+
qCDebug(customcommand) << "Command execution complete";
7485
}
7586

7687
void CustomCommandPlugin::doShowPlugin(const QString name, bool bSetFocus)
7788
{
89+
qCDebug(customcommand) << "Show plugin called for:" << name << "with focus:" << bSetFocus;
7890
if (MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND != name) {
7991
// 若插件已经显示,则隐藏
8092
if (m_isShow) {
81-
qCWarning(customcommand) << "Command top panel hide";
93+
qCInfo(customcommand) << "Hiding command top panel";
8294
getCustomCommandTopPanel()->hideAnim();
8395
m_isShow = false;
8496
}
8597
} else {
8698
/******** Add by nt001000 renfeixiang 2020-05-18:修改雷神窗口太小时,自定义界面使用不方便,将雷神窗口变大适应正常的自定义界面 Begin***************/
8799
if (m_mainWindow->isQuakeMode() && m_mainWindow->height() < LISTMINHEIGHT) {
100+
qCDebug(customcommand) << "Adjusting quake window size for command panel";
88101
//因为拉伸函数设置了FixSize,导致自定义界面弹出时死循环,然后崩溃的问题
89102
QuakeWindow *quakeWindow = qobject_cast<QuakeWindow *>(m_mainWindow);
90-
if(!quakeWindow)
103+
if(!quakeWindow) {
104+
qCWarning(customcommand) << "Failed to cast to QuakeWindow";
91105
return;
106+
}
92107
quakeWindow->switchEnableResize(true);
93108
m_mainWindow->resize(m_mainWindow->width(), LISTMINHEIGHT); //首先设置雷神界面的大小
94109
m_mainWindow->showPlugin(MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND);//重新打开自定义界面,当前流程结束
95110
//窗口弹出后,重新判断雷神窗口是否需要有拉伸属性
96111
quakeWindow->switchEnableResize();
112+
qCDebug(customcommand) << "Quake window size adjusted";
97113
return;
98114
}
99115
/******** Add by nt001000 renfeixiang 2020-05-18:修改雷神窗口太小时,自定义界面使用不方便,将雷神窗口变大适应正常的自定义界面 End***************/
116+
qCInfo(customcommand) << "Showing command top panel";
100117
getCustomCommandTopPanel()->show(bSetFocus);
101118
m_isShow = true;
102119
}

0 commit comments

Comments
 (0)