Skip to content

Commit ed0509c

Browse files
committed
fix: use QJsonObject for event logger messages
Use QJsonObject directly for EventLoggerData messages so JSON payloads are preserved when writing event logs. Remove the string key/value helper that no longer matches the object-based message payload. 使用 QJsonObject 直接承载 EventLoggerData 的 message 字段,确保写入事件日志时保留 JSON 载荷内容。移除不再匹配对象化 message 载荷的字符串键值辅助接口。
1 parent 01b26dc commit ed0509c

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

cpp-include/eventlogger.hpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ typedef struct _EventLoggerData
4040
{
4141
qint64 tid;
4242
QString target;
43-
QMap<QString, QString> message;
43+
QJsonObject message;
4444

4545
_EventLoggerData()
4646
: tid(0)
4747
, target(QString())
48-
, message(QMap<QString, QString>())
48+
, message(QJsonObject())
4949
{
5050
}
5151

52-
_EventLoggerData(qint64 tid, const QString &target, const QMap<QString, QString> &message)
52+
_EventLoggerData(qint64 tid, const QString &target, const QJsonObject &message)
5353
: tid(tid)
5454
, target(target)
5555
, message(message)
@@ -89,11 +89,6 @@ class EventLogger
8989
m_writeEventLog(json.toJson(QJsonDocument::Compact).toStdString());
9090
}
9191

92-
void writeEventLog(qint64 tid, const QString &target, const QString &key, const QString &value)
93-
{
94-
writeEventLog(EventLoggerData(tid, target, {{key, value}}));
95-
}
96-
9792
bool init(QString package_id, bool enable_sig)
9893
{
9994
if (!shouldEnableEventLog()) {
@@ -153,14 +148,7 @@ class EventLogger
153148
QJsonObject jsonObject;
154149
jsonObject["tid"] = data.tid;
155150
jsonObject["target"] = data.target;
156-
QJsonObject msgJson;
157-
QMapIterator<QString, QString> iterator(data.message);
158-
while (iterator.hasNext()) {
159-
iterator.next();
160-
msgJson[iterator.key()] = iterator.value();
161-
}
162-
163-
jsonObject["message"] = msgJson;
151+
jsonObject["message"] = data.message;
164152
QJsonDocument jsonDocument(jsonObject);
165153
return jsonDocument;
166154
}

0 commit comments

Comments
 (0)