Skip to content

Commit b1d12cb

Browse files
committed
chore: [log]More logs
Add more logs for log coverage. Log: Add more logs.
1 parent c5d4566 commit b1d12cb

48 files changed

Lines changed: 706 additions & 81 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/CSyntaxHighlighter.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,28 @@ CSyntaxHighlighter::CSyntaxHighlighter(QObject *parent):
99
SyntaxHighlighter (parent),
1010
m_bHighlight(false)
1111
{
12-
12+
qDebug() << "CSyntaxHighlighter constructor";
1313
}
1414

1515
CSyntaxHighlighter::CSyntaxHighlighter(QTextDocument *pDocument):
1616
SyntaxHighlighter (pDocument),m_bHighlight(false)
1717
{
18-
18+
qDebug() << "CSyntaxHighlighter constructor with QTextDocument*";
1919
}
2020

2121
void CSyntaxHighlighter::setEnableHighlight(bool isEnable)
2222
{
23+
qDebug() << "CSyntaxHighlighter::setEnableHighlight()" << isEnable;
2324
m_bHighlight = isEnable;
2425
}
2526

2627
void CSyntaxHighlighter::highlightBlock(const QString &text)
2728
{
2829
if (!m_bHighlight) {
30+
qDebug() << "CSyntaxHighlighter::highlightBlock() is disabled";
2931
return;
3032
}
3133

34+
qDebug() << "CSyntaxHighlighter::highlightBlock()";
3235
KSyntaxHighlighting::SyntaxHighlighter::highlightBlock(text);
3336
}

src/common/config.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const QString g_keyEnablePatchedIconv = "enablePatchedIconv";
2525
*/
2626
bool detectIconvUse2005Standard()
2727
{
28+
qDebug() << "Detecting iconv use GB18030-2005 standard";
2829
iconv_t handle = iconv_open("UTF-8", "GB18030");
2930
if (handle == reinterpret_cast<iconv_t>(-1)) {
31+
qWarning() << "Failed to open iconv handle for GB18030";
3032
return true;
3133
}
3234

@@ -41,15 +43,16 @@ bool detectIconvUse2005Standard()
4143
iconv_close(handle);
4244

4345
if (ret == static_cast<size_t>(-1)) {
46+
qWarning() << "Failed to convert GB18030 to UTF-8";
4447
return true;
4548
}
4649

4750
if (!output.contains("\uE816")) {
48-
qInfo() << "Current iconv gb18030 standard is 2005.";
51+
qInfo() << "Current iconv uses GB18030-2005 standard";
4952
return true;
5053
}
5154

52-
qInfo() << "Current iconv gb18030 standard is 2022.";
55+
qInfo() << "Current iconv uses GB18030-2022 standard";
5356
return false;
5457
}
5558

@@ -64,6 +67,7 @@ Config::Config(QObject *parent)
6467
: QObject(parent)
6568
, encoding("UTF-8")
6669
{
70+
qDebug() << "Initializing Config instance";
6771
#ifdef DTKCORE_CLASS_DConfigFile
6872
dconfig = DConfig::create("org.deepin.editor", "org.deepin.editor");
6973
if (dconfig->isValid()) {
@@ -103,6 +107,7 @@ Config::Config(QObject *parent)
103107

104108
Config::~Config()
105109
{
110+
qDebug() << "Destroying Config instance";
106111
#ifdef DTKCORE_CLASS_DConfigFile
107112
if (dconfig) {
108113
delete dconfig;
@@ -112,6 +117,7 @@ Config::~Config()
112117

113118
Config *Config::instance()
114119
{
120+
qDebug() << "Getting Config singleton instance";
115121
static Config config;
116122
return &config;
117123
}

src/common/dbusinterface.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44

55
#include "dbusinterface.h"
66

7+
#include <QDebug>
8+
79
SaveFileInterface::SaveFileInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
810
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
911
{
12+
qDebug() << "SaveFileInterface created for" << service << path;
1013
}
1114

1215
SaveFileInterface::~SaveFileInterface()
1316
{
17+
qDebug() << "SaveFileInterface destroyed for" << service() << path();
1418
}

src/common/eventlogutils.cpp

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

1112
Eventlogutils *Eventlogutils::m_pInstance = nullptr;
1213
Eventlogutils *Eventlogutils::GetInstance()
1314
{
15+
qDebug() << "Eventlogutils::GetInstance()";
1416
if (m_pInstance == nullptr) {
1517
m_pInstance = new Eventlogutils();
1618
}
@@ -19,20 +21,25 @@ Eventlogutils *Eventlogutils::GetInstance()
1921

2022
void Eventlogutils::writeLogs(QJsonObject &data)
2123
{
22-
if (!writeEventLogFunc)
24+
if (!writeEventLogFunc) {
25+
qWarning() << "writeEventLogFunc is not initialized";
2326
return;
27+
}
2428

2529
writeEventLogFunc(QJsonDocument(data).toJson(QJsonDocument::Compact).toStdString());
2630
}
2731

2832
Eventlogutils::Eventlogutils()
2933
{
34+
qDebug() << "Eventlogutils::Eventlogutils()";
3035
QLibrary library("libdeepin-event-log.so");
3136
initFunc = reinterpret_cast<bool (*)(const std::string &, bool)>(library.resolve("Initialize"));
3237
writeEventLogFunc = reinterpret_cast<void (*)(const std::string &)>(library.resolve("WriteEventLog"));
3338

34-
if (!initFunc)
39+
if (!initFunc) {
40+
qWarning() << "Failed to load libdeepin-event-log.so";
3541
return;
42+
}
3643

3744
initFunc("deepin-editor", true);
3845
}

src/common/fileloadthread.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ FileLoadThread::FileLoadThread(const QString &filepath, QObject *parent)
1212
: QThread(parent),
1313
m_strFilePath(filepath)
1414
{
15-
15+
qDebug() << "Creating FileLoadThread for file:" << filepath;
1616
}
1717

1818
FileLoadThread::~FileLoadThread()
1919
{
20+
qDebug() << "Destroying FileLoadThread for file:" << m_strFilePath;
2021
}
2122

2223
void FileLoadThread::run()
2324
{
25+
qDebug() << "Starting file load thread for:" << m_strFilePath;
2426
QFile file(m_strFilePath);
2527

2628
if (file.open(QIODevice::ReadOnly)) {
@@ -30,9 +32,11 @@ void FileLoadThread::run()
3032
// 判断文件大小是否超过40MB, 超过40MB的文件过大,需要调整读取策略,优先加载头部文件
3133
static const int s_maxDirectReadLen = 40 * DATA_SIZE_1024 * DATA_SIZE_1024;
3234
if (file.size() > s_maxDirectReadLen) {
35+
qDebug() << "Large file detected (" << file.size() << " bytes), using optimized loading strategy";
3336
// 先读取1MB数据
3437
indata = file.read(DATA_SIZE_1024 * DATA_SIZE_1024);
3538
encode = DetectCode::GetFileEncodingFormat(m_strFilePath, indata);
39+
qDebug() << "Initial encoding detection result:" << encode;
3640

3741
// 发送文件头信息,用于预先加载数据
3842
QString textEncode = QString::fromLocal8Bit(encode);
@@ -47,18 +51,21 @@ void FileLoadThread::run()
4751

4852
// 读取申请开辟内存空间时,捕获可能出现的 std::bad_alloc() 异常,防止闪退。
4953
try {
54+
qDebug() << "Reading remaining file content";
5055
// reads all remaining data from the file.
5156
indata += file.read(file.size());
5257
file.close();
58+
qDebug() << "Total bytes read:" << indata.size();
5359
} catch (const std::exception &e) {
54-
qWarning() << Q_FUNC_INFO << "Read file data error, " << QString(e.what());
60+
qWarning() << "FileLoadThread read error:" << e.what() << "at" << m_strFilePath;
5561

5662
file.close();
5763
emit sigLoadFinished(encode, indata, true);
5864
return;
5965
}
6066

6167
if (encode.isEmpty()) {
68+
qDebug() << "Performing full encoding detection";
6269
//编码识别,如果文件数据大于1M,则只裁剪出1M文件数据去做编码探测
6370
QByteArray dateUsedForCodeIdentify;
6471
if (indata.length() > DATA_SIZE_1024 * DATA_SIZE_1024) {
@@ -70,15 +77,21 @@ void FileLoadThread::run()
7077
}
7178

7279
QString textEncode = QString::fromLocal8Bit(encode);
80+
qDebug() << "Final encoding detected:" << textEncode;
7381
if (textEncode.contains("ASCII", Qt::CaseInsensitive) || textEncode.contains("UTF-8", Qt::CaseInsensitive)) {
82+
qDebug() << "Using original encoding, no conversion needed";
7483
emit sigLoadFinished(encode, indata, false);
7584
} else {
85+
qDebug() << "Converting from" << textEncode << "to UTF-8";
7686
QByteArray outData;
7787
DetectCode::ChangeFileEncodingFormat(indata, outData, textEncode, QString("UTF-8"));
7888
emit sigLoadFinished(encode, outData, false);
89+
qDebug() << "Encoding conversion completed, output size:" << outData.size();
7990
}
8091
}
8192

93+
qDebug() << "FileLoadThread finished processing:" << m_strFilePath;
8294
this->quit();
8395
this->deleteLater();
96+
qDebug() << "FileLoadThread resources cleaned up";
8497
}

0 commit comments

Comments
 (0)