Skip to content

Commit 3e0cf7b

Browse files
re2zerodeepin-bot[bot]
authored andcommitted
chore: Add more logs.
Add more logs. Log: Add more logs.
1 parent b62607c commit 3e0cf7b

24 files changed

Lines changed: 939 additions & 203 deletions

src/dcc-fcitx5configtool/operation/fcitx5addonsproxy.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,25 @@
1111
#include <fcitx-utils/standardpath.h>
1212

1313
#include <QDBusPendingCallWatcher>
14+
#include <QLoggingCategory>
15+
16+
Q_LOGGING_CATEGORY(addonsProxy, "fcitx5.configtool.addonsproxy")
1417

1518
using namespace deepin::fcitx5configtool;
1619

1720
Fcitx5AddonsProxyPrivate::Fcitx5AddonsProxyPrivate(Fcitx5AddonsProxy *parent, fcitx::kcm::DBusProvider *dbus)
1821
: q(parent), dbusprovider(dbus)
1922
{
23+
qCDebug(addonsProxy) << "Entering Fcitx5AddonsProxyPrivate constructor";
2024
}
2125

2226
void Fcitx5AddonsProxyPrivate::fetchAddonsFinished(QDBusPendingCallWatcher *watcher)
2327
{
24-
qDebug() << "Entering fetchAddonsFinished";
28+
qCDebug(addonsProxy) << "Entering fetchAddonsFinished";
2529
watcher->deleteLater();
2630

2731
if (watcher->isError()) {
28-
qWarning() << "Failed to fetch addons:" << watcher->error().message();
32+
qCWarning(addonsProxy) << "Failed to fetch addons:" << watcher->error().message();
2933
return;
3034
}
3135
QDBusPendingReply<fcitx::FcitxQtAddonInfoV2List> reply(*watcher);
@@ -65,40 +69,45 @@ void Fcitx5AddonsProxyPrivate::fetchAddonsFinished(QDBusPendingCallWatcher *watc
6569
}
6670

6771
Q_EMIT q->requestAddonsFinished();
68-
qDebug() << "Finished processing addons data";
72+
qCDebug(addonsProxy) << "Exiting fetchAddonsFinished";
6973
}
7074

7175
Fcitx5AddonsProxy::Fcitx5AddonsProxy(fcitx::kcm::DBusProvider *dbus, QObject *parent)
7276
: QObject(parent), d(new Fcitx5AddonsProxyPrivate(this, dbus))
7377
{
78+
qCDebug(addonsProxy) << "Entering Fcitx5AddonsProxy constructor";
7479
}
7580

7681
Fcitx5AddonsProxy::~Fcitx5AddonsProxy() = default;
7782

7883
void Fcitx5AddonsProxy::clear()
7984
{
85+
qCDebug(addonsProxy) << "Entering clear";
8086
d->nameToAddonMap.clear();
8187
d->reverseDependencies.clear();
8288
d->reverseOptionalDependencies.clear();
8389
d->addonEntryList.clear();
90+
qCDebug(addonsProxy) << "Exiting clear";
8491
}
8592

8693
void Fcitx5AddonsProxy::load()
8794
{
88-
qDebug() << "Loading fcitx5 addons";
95+
qCDebug(addonsProxy) << "Entering load";
8996
if (!d->dbusprovider->controller()) {
90-
qWarning() << "DBus controller not available";
97+
qCWarning(addonsProxy) << "DBus controller not available for load";
9198
return;
9299
}
93100

94101
auto call = d->dbusprovider->controller()->GetAddonsV2();
95102
auto watcher = new QDBusPendingCallWatcher(call, this);
96103
connect(watcher, &QDBusPendingCallWatcher::finished, d,
97104
&Fcitx5AddonsProxyPrivate::fetchAddonsFinished);
105+
qCDebug(addonsProxy) << "Exiting load";
98106
}
99107

100108
QVariantList Fcitx5AddonsProxy::globalAddons() const
101109
{
110+
qCDebug(addonsProxy) << "Entering globalAddons";
102111
QVariantList ret;
103112
for (const auto &entry : d->addonEntryList) {
104113
for (const auto &addonUniqueName : entry.second) {
@@ -115,16 +124,16 @@ QVariantList Fcitx5AddonsProxy::globalAddons() const
115124
addonMap["optionalDependencies"] = addon.optionalDependencies();
116125
ret.append(QVariant::fromValue(addonMap));
117126
}
118-
qDebug() << "Addon state changed successfully";
119127
}
128+
qCDebug(addonsProxy) << "Exiting globalAddons with" << ret.size() << "items";
120129
return ret;
121130
}
122131

123132
void Fcitx5AddonsProxy::setEnableAddon(const QString &addonStr, bool enable)
124133
{
125-
qDebug() << "Setting addon" << addonStr << "enable state to" << enable;
134+
qCDebug(addonsProxy) << "Entering setEnableAddon for addon" << addonStr << "with enable state" << enable;
126135
if (!d->nameToAddonMap.contains(addonStr)) {
127-
qWarning() << "Addon not found:" << addonStr;
136+
qCWarning(addonsProxy) << "Addon not found:" << addonStr;
128137
return;
129138
}
130139

@@ -137,10 +146,12 @@ void Fcitx5AddonsProxy::setEnableAddon(const QString &addonStr, bool enable)
137146
list.append(state);
138147

139148
if (list.size()) {
149+
qCInfo(addonsProxy) << "Setting addon states and restarting fcitx5.";
140150
d->dbusprovider->controller()->SetAddonsState(list);
141151
QProcess p;
142152
p.start("killall", QStringList() << "fcitx5");
143153
p.waitForFinished();
144154
QProcess::startDetached(QString::fromStdString(fcitx::StandardPath::fcitxPath("bindir", "fcitx5")), QStringList());
145155
}
156+
qCDebug(addonsProxy) << "Exiting setEnableAddon";
146157
}

src/dcc-fcitx5configtool/operation/fcitx5configproxy.cpp

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include <varianthelper.h>
1010

1111
#include <QDBusPendingCallWatcher>
12+
#include <QLoggingCategory>
13+
14+
Q_LOGGING_CATEGORY(proxy, "fcitx5.configtool.proxy")
1215

1316
using namespace deepin::fcitx5configtool;
1417

@@ -17,14 +20,16 @@ Fcitx5ConfigProxyPrivate::Fcitx5ConfigProxyPrivate(Fcitx5ConfigProxy *parent,
1720
const QString &path)
1821
: q(parent), dbusprovider(dbus), path(path)
1922
{
20-
qDebug() << "Initializing Fcitx5ConfigProxy for path:" << path;
23+
qCDebug(proxy) << "Entering Fcitx5ConfigProxyPrivate constructor for path:" << path;
2124
timer = new QTimer(q);
2225
timer->setInterval(1000);
2326
timer->setSingleShot(true);
2427
connect(timer, &QTimer::timeout, q, &Fcitx5ConfigProxy::save);
28+
qCDebug(proxy) << "Exiting Fcitx5ConfigProxyPrivate constructor";
2529
}
2630

2731
QStringList Fcitx5ConfigProxyPrivate::formatKey(const QString &shortcut) {
32+
qCDebug(proxy) << "Formatting key from shortcut:" << shortcut;
2833
QStringList list;
2934
for (const auto &key : shortcut.split("+")) {
3035
if (key.trimmed().toLower() == "control")
@@ -57,10 +62,12 @@ QStringList Fcitx5ConfigProxyPrivate::formatKey(const QString &shortcut) {
5762
list.removeAll("Shift_R");
5863
}
5964
}
65+
qCDebug(proxy) << "Formatted key list:" << list;
6066
return list;
6167
}
6268

6369
QString Fcitx5ConfigProxyPrivate::formatKeys(const QStringList &keys) {
70+
qCDebug(proxy) << "Formatting keys from list:" << keys;
6471
QStringList list;
6572
for (const auto &key : keys) {
6673
if (key.trimmed().toLower() == "ctrl")
@@ -117,20 +124,23 @@ QVariant Fcitx5ConfigProxyPrivate::readDBusValue(const QVariant &value) {
117124
Fcitx5ConfigProxy::Fcitx5ConfigProxy(fcitx::kcm::DBusProvider *dbus, const QString &path, QObject *parent)
118125
: QObject(parent), d(new Fcitx5ConfigProxyPrivate(this, dbus, path))
119126
{
120-
qDebug() << "Fcitx5ConfigProxy created for path:" << path;
127+
qCDebug(proxy) << "Entering Fcitx5ConfigProxy constructor for path:" << path;
121128
}
122129

123130
Fcitx5ConfigProxy::~Fcitx5ConfigProxy() = default;
124131

125132
void Fcitx5ConfigProxy::clear()
126133
{
134+
qCDebug(proxy) << "Entering clear";
127135
d->configValue.clear();
128136
d->configTypes.clear();
129137
Q_EMIT requestConfigFinished();
138+
qCDebug(proxy) << "Exiting clear";
130139
}
131140

132141
QVariantList Fcitx5ConfigProxy::globalConfigTypes() const
133142
{
143+
qCDebug(proxy) << "Entering globalConfigTypes";
134144
QVariantList list;
135145
for (const auto &type : d->configTypes) {
136146
if (type.name() == "GlobalConfig") {
@@ -143,11 +153,13 @@ QVariantList Fcitx5ConfigProxy::globalConfigTypes() const
143153
break;
144154
}
145155
}
156+
qCDebug(proxy) << "Exiting globalConfigTypes with" << list.size() << "items";
146157
return list;
147158
}
148159

149160
QVariantList Fcitx5ConfigProxy::globalConfigOptions(const QString &type, bool all) const
150161
{
162+
qCDebug(proxy) << "Entering globalConfigOptions for type" << type << "all:" << all;
151163
QVariantList list;
152164
QString currentType = type+"$"+type+"Config";
153165
for (const auto &configType : d->configTypes) {
@@ -212,11 +224,13 @@ QVariantList Fcitx5ConfigProxy::globalConfigOptions(const QString &type, bool al
212224
}
213225
break;
214226
}
227+
qCDebug(proxy) << "Exiting globalConfigOptions with" << list.size() << "items";
215228
return list;
216229
}
217230

218231
QVariant Fcitx5ConfigProxy::globalConfigOption(const QString &type, const QString &optionName) const
219232
{
233+
qCDebug(proxy) << "Entering globalConfigOption for type" << type << "option:" << optionName;
220234
QVariantMap item;
221235
QString currentType = type+"$"+type+"Config";
222236
for (const auto &configType : d->configTypes) {
@@ -280,11 +294,13 @@ QVariant Fcitx5ConfigProxy::globalConfigOption(const QString &type, const QStrin
280294
}
281295
break;
282296
}
297+
qCDebug(proxy) << "Exiting globalConfigOption with item" << item;
283298
return item;
284299
}
285300

286301
void Fcitx5ConfigProxy::restoreDefault(const QString &type)
287302
{
303+
qCDebug(proxy) << "Entering restoreDefault for type" << type;
288304
QString currentType = type+"$"+type+"Config";
289305
for (const auto &configType : d->configTypes) {
290306
if (configType.name() != currentType)
@@ -295,13 +311,14 @@ void Fcitx5ConfigProxy::restoreDefault(const QString &type)
295311
}
296312
break;
297313
}
314+
qCDebug(proxy) << "Exiting restoreDefault";
298315
}
299316

300317
void Fcitx5ConfigProxy::requestConfig(bool sync)
301318
{
302-
qDebug() << "Requesting config for path:" << d->path << "sync:" << sync;
319+
qCDebug(proxy) << "Entering requestConfig for path" << d->path << "with sync" << sync;
303320
if (!d->dbusprovider->controller()) {
304-
qWarning() << "DBus controller not available";
321+
qCWarning(proxy) << "DBus controller not available for requestConfig";
305322
return;
306323
}
307324
auto call = d->dbusprovider->controller()->GetConfig(d->path);
@@ -311,20 +328,22 @@ void Fcitx5ConfigProxy::requestConfig(bool sync)
311328
this,
312329
&Fcitx5ConfigProxy::onRequestConfigFinished);
313330
if (sync) {
331+
qCDebug(proxy) << "Waiting for requestConfig to finish";
314332
watcher->waitForFinished();
315333
}
334+
qCDebug(proxy) << "Exiting requestConfig";
316335
}
317336

318337
void Fcitx5ConfigProxy::onRequestConfigFinished(QDBusPendingCallWatcher *watcher)
319338
{
320-
qDebug() << "Processing config response for path:" << d->path;
339+
qCDebug(proxy) << "Entering onRequestConfigFinished for path" << d->path;
321340
watcher->deleteLater();
322341
QDBusPendingReply<QDBusVariant, fcitx::FcitxQtConfigTypeList> reply = *watcher;
323342
if (reply.isError()) {
324-
qWarning() << "Failed to get config:" << reply.error();
343+
qCWarning(proxy) << "Failed to get config for path" << d->path << "Error:" << reply.error();
325344
return;
326345
}
327-
qDebug() << "Successfully received config for path:" << d->path;
346+
qCInfo(proxy) << "Successfully received config for path:" << d->path;
328347
d->configTypes = reply.argumentAt<1>();
329348

330349
auto value = reply.argumentAt<0>().variant();
@@ -333,39 +352,44 @@ void Fcitx5ConfigProxy::onRequestConfigFinished(QDBusPendingCallWatcher *watcher
333352
std::swap(d->configValue, allMap);
334353

335354
Q_EMIT requestConfigFinished();
355+
qCDebug(proxy) << "Exiting onRequestConfigFinished";
336356
}
337357

338358
QVariant Fcitx5ConfigProxy::value(const QString &path) const
339359
{
340-
qDebug() << "Getting value for config path:" << path;
360+
qCDebug(proxy) << "Entering value for path:" << path;
341361
return fcitx::kcm::readVariant(d->configValue, path);
342362
}
343363

344364
void Fcitx5ConfigProxy::setValue(const QString &path, const QVariant &value, bool isKey)
345365
{
346-
qDebug() << "Setting value for config path:" << path << "isKey:" << isKey;
366+
qCDebug(proxy) << "Setting value for config path:" << path << "isKey:" << isKey;
347367
if (value == this->value(path)) {
348-
qDebug() << "Value unchanged, skipping update";
368+
qCDebug(proxy) << "Value unchanged, skipping update for path:" << path;
349369
return;
350370
}
351371
if (isKey) {
372+
qCDebug(proxy) << "Formatting keys for path:" << path;
352373
auto keys = d->formatKeys(value.toStringList());
353374
fcitx::kcm::writeVariant(d->configValue, path, keys);
354375
} else {
376+
qCDebug(proxy) << "Writing value for path:" << path;
355377
fcitx::kcm::writeVariant(d->configValue, path, value);
356378
}
357379
d->timer->start();
380+
qCDebug(proxy) << "Exiting setValue";
358381
}
359382

360383
void Fcitx5ConfigProxy::save()
361384
{
362-
qDebug() << "Saving config changes for path:" << d->path;
385+
qCDebug(proxy) << "Entering save for path:" << d->path;
363386
if (!d->dbusprovider->controller()) {
364-
qWarning() << "DBus controller not available";
387+
qCWarning(proxy) << "DBus controller not available for save";
365388
return;
366389
}
367390

368391
QDBusVariant var(d->configValue);
369392
d->dbusprovider->controller()->SetConfig(d->path, var);
370393
requestConfig(false);
394+
qCDebug(proxy) << "Exiting save";
371395
}

0 commit comments

Comments
 (0)