From 3fa1ee3c6b04d0793ccca3f903797625f7a08d03 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sun, 30 Apr 2017 15:19:31 +0200 Subject: Port to categorized logging This greatly reduces the noise made by quaternion. To enable full logging, export the following variable: QT_LOGGING_RULES="libqmatrixclient.*.debug=true" --- events/event.cpp | 8 ++++---- events/receiptevent.cpp | 5 +++-- events/roomaliasesevent.cpp | 3 ++- events/roommemberevent.cpp | 3 ++- events/roommessageevent.cpp | 10 +++++----- events/typingevent.cpp | 3 ++- events/unknownevent.cpp | 4 ++-- 7 files changed, 20 insertions(+), 16 deletions(-) (limited to 'events') diff --git a/events/event.cpp b/events/event.cpp index 8ad56f1b..b3f75ca9 100644 --- a/events/event.cpp +++ b/events/event.cpp @@ -124,8 +124,8 @@ bool Event::parseJson(const QJsonObject& obj) if (d->id.isEmpty()) { correct = false; - qDebug() << "Event: can't find event_id; event dump follows"; - qDebug() << formatJson << obj; + qCDebug(EVENTS) << "Event: can't find event_id; event dump follows"; + qCDebug(EVENTS) << formatJson << obj; } if( obj.contains("origin_server_ts") ) { @@ -135,8 +135,8 @@ bool Event::parseJson(const QJsonObject& obj) else if (d->type != EventType::Unknown) { correct = false; - qDebug() << "Event: can't find ts; event dump follows"; - qDebug() << formatJson << obj; + qCDebug(EVENTS) << "Event: can't find ts; event dump follows"; + qCDebug(EVENTS) << formatJson << obj; } } return correct; diff --git a/events/receiptevent.cpp b/events/receiptevent.cpp index 8029045a..5d11a0dd 100644 --- a/events/receiptevent.cpp +++ b/events/receiptevent.cpp @@ -34,6 +34,7 @@ Example of a Receipt Event: */ #include "receiptevent.h" +#include "util.h" #include #include @@ -72,8 +73,8 @@ ReceiptEvent* ReceiptEvent::fromJson(const QJsonObject& obj) { if (eventIt.key().isEmpty()) { - qWarning() << "ReceiptEvent has an empty event id, skipping"; - qDebug() << "ReceiptEvent content follows:\n" << contents; + qCWarning(EVENTS) << "ReceiptEvent has an empty event id, skipping"; + qCDebug(EVENTS) << "ReceiptEvent content follows:\n" << contents; continue; } const QJsonObject reads = eventIt.value().toObject().value("m.read").toObject(); diff --git a/events/roomaliasesevent.cpp b/events/roomaliasesevent.cpp index 9c64e40c..e0dbdb38 100644 --- a/events/roomaliasesevent.cpp +++ b/events/roomaliasesevent.cpp @@ -33,6 +33,7 @@ // } #include "roomaliasesevent.h" +#include "util.h" #include #include @@ -71,6 +72,6 @@ RoomAliasesEvent* RoomAliasesEvent::fromJson(const QJsonObject& obj) { e->d->aliases << alias.toString(); } - qDebug() << "RoomAliasesEvent:" << e->d->aliases; + qCDebug(EVENTS) << "RoomAliasesEvent:" << e->d->aliases; return e; } diff --git a/events/roommemberevent.cpp b/events/roommemberevent.cpp index 93b4bb32..0dafd303 100644 --- a/events/roommemberevent.cpp +++ b/events/roommemberevent.cpp @@ -17,6 +17,7 @@ */ #include "roommemberevent.h" +#include "util.h" #include @@ -81,7 +82,7 @@ RoomMemberEvent* RoomMemberEvent::fromJson(const QJsonObject& obj) else if( membershipString == "ban" ) e->d->membership = MembershipType::Ban; else - qDebug() << "Unknown MembershipType: " << membershipString; + qCDebug(EVENTS) << "Unknown MembershipType: " << membershipString; e->d->avatarUrl = QUrl(content.value("avatar_url").toString()); return e; } diff --git a/events/roommessageevent.cpp b/events/roommessageevent.cpp index f5dcb7d0..fd6de464 100644 --- a/events/roommessageevent.cpp +++ b/events/roommessageevent.cpp @@ -97,8 +97,8 @@ ContentPair makeVideo(const QJsonObject& json) ContentPair makeUnknown(const QJsonObject& json) { - qDebug() << "RoomMessageEvent: couldn't resolve msgtype, JSON follows:"; - qDebug() << json; + qCDebug(EVENTS) << "RoomMessageEvent: couldn't resolve msgtype, JSON follows:"; + qCDebug(EVENTS) << json; return { MessageEventType::Unknown, new Base }; } @@ -110,7 +110,7 @@ RoomMessageEvent* RoomMessageEvent::fromJson(const QJsonObject& obj) { e->d->userId = obj.value("sender").toString(); } else { - qDebug() << "RoomMessageEvent: user_id not found"; + qCDebug(EVENTS) << "RoomMessageEvent: user_id not found"; } if( obj.contains("content") ) { @@ -135,8 +135,8 @@ RoomMessageEvent* RoomMessageEvent::fromJson(const QJsonObject& obj) } else { - qWarning() << "RoomMessageEvent(" << e->id() << "): no body or msgtype"; - qDebug() << obj; + qCWarning(EVENTS) << "RoomMessageEvent(" << e->id() << "): no body or msgtype"; + qCDebug(EVENTS) << obj; } } return e; diff --git a/events/typingevent.cpp b/events/typingevent.cpp index 36a7e693..11c3a565 100644 --- a/events/typingevent.cpp +++ b/events/typingevent.cpp @@ -17,6 +17,7 @@ */ #include "typingevent.h" +#include "util.h" #include #include @@ -54,6 +55,6 @@ TypingEvent* TypingEvent::fromJson(const QJsonObject& obj) { e->d->users << user.toString(); } - qDebug() << "Typing:" << e->d->users; + qCDebug(EVENTS) << "Typing:" << e->d->users; return e; } diff --git a/events/unknownevent.cpp b/events/unknownevent.cpp index 70dcfcbb..b2947bf7 100644 --- a/events/unknownevent.cpp +++ b/events/unknownevent.cpp @@ -59,7 +59,7 @@ UnknownEvent* UnknownEvent::fromJson(const QJsonObject& obj) e->parseJson(obj); e->d->type = obj.value("type").toString(); e->d->content = QString::fromUtf8(QJsonDocument(obj).toJson()); - qDebug() << "UnknownEvent, JSON follows:"; - qDebug() << formatJson << obj; + qCDebug(EVENTS) << "UnknownEvent, JSON follows:"; + qCDebug(EVENTS) << formatJson << obj; return e; } -- cgit v1.2.3