diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-05-01 01:54:53 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-01 01:54:53 +0900 |
commit | 096a05d59654244f7c928dc5f2537a760070a577 (patch) | |
tree | 1ee17f9016b0f333c08cf5d0eb0c8a8ab86a8573 | |
parent | 9a13bbfd8a800712d0a2fcc4887c8d4115d06d4e (diff) | |
parent | 3fa1ee3c6b04d0793ccca3f903797625f7a08d03 (diff) | |
download | libquotient-096a05d59654244f7c928dc5f2537a760070a577.tar.gz libquotient-096a05d59654244f7c928dc5f2537a760070a577.zip |
Merge pull request #61 from elvisangelaccio/qloggingcategory
Port to categorized logging
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | connection.cpp | 8 | ||||
-rw-r--r-- | connectiondata.cpp | 5 | ||||
-rw-r--r-- | debug.cpp | 30 | ||||
-rw-r--r-- | events/event.cpp | 8 | ||||
-rw-r--r-- | events/receiptevent.cpp | 5 | ||||
-rw-r--r-- | events/roomaliasesevent.cpp | 3 | ||||
-rw-r--r-- | events/roommemberevent.cpp | 3 | ||||
-rw-r--r-- | events/roommessageevent.cpp | 10 | ||||
-rw-r--r-- | events/typingevent.cpp | 3 | ||||
-rw-r--r-- | events/unknownevent.cpp | 4 | ||||
-rw-r--r-- | jobs/basejob.cpp | 17 | ||||
-rw-r--r-- | jobs/joinroomjob.cpp | 3 | ||||
-rw-r--r-- | jobs/mediathumbnailjob.cpp | 3 | ||||
-rw-r--r-- | jobs/postmessagejob.cpp | 3 | ||||
-rw-r--r-- | jobs/roommessagesjob.cpp | 2 | ||||
-rw-r--r-- | jobs/syncjob.cpp | 4 | ||||
-rw-r--r-- | room.cpp | 37 | ||||
-rw-r--r-- | settings.cpp | 2 | ||||
-rw-r--r-- | user.cpp | 3 | ||||
-rw-r--r-- | util.h | 8 |
21 files changed, 103 insertions, 59 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 16b66c3e..4692605c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ message( STATUS ) set(libqmatrixclient_SRCS connectiondata.cpp connection.cpp + debug.cpp room.cpp user.cpp state.cpp diff --git a/connection.cpp b/connection.cpp index 25786361..0fc23f2f 100644 --- a/connection.cpp +++ b/connection.cpp @@ -74,7 +74,7 @@ Connection::Connection() Connection::~Connection() { - qDebug() << "deconstructing connection object for" << d->userId; + qCDebug(MAIN) << "deconstructing connection object for" << d->userId; delete d; } @@ -121,10 +121,10 @@ void Connection::connectWithToken(QString userId, QString token) d->isConnected = true; d->userId = userId; d->data->setToken(token); - qDebug() << "Accessing" << d->data->baseUrl() + qCDebug(MAIN) << "Accessing" << d->data->baseUrl() << "by user" << userId << "with the following access token:"; - qDebug() << token; + qCDebug(MAIN) << token; emit connected(); } @@ -307,7 +307,7 @@ Room* Connection::provideRoom(QString id) { if (id.isEmpty()) { - qDebug() << "Connection::provideRoom() with empty id, doing nothing"; + qCDebug(MAIN) << "Connection::provideRoom() with empty id, doing nothing"; return nullptr; } diff --git a/connectiondata.cpp b/connectiondata.cpp index 4f50fb88..a6d80d53 100644 --- a/connectiondata.cpp +++ b/connectiondata.cpp @@ -17,6 +17,7 @@ */ #include "connectiondata.h" +#include "util.h" #include <QtCore/QDebug> #include <QtNetwork/QNetworkAccessManager> @@ -70,13 +71,13 @@ void ConnectionData::setToken(QString token) void ConnectionData::setHost(QString host) { d->baseUrl.setHost(host); - qDebug() << "updated baseUrl to" << d->baseUrl; + qCDebug(MAIN) << "updated baseUrl to" << d->baseUrl; } void ConnectionData::setPort(int port) { d->baseUrl.setPort(port); - qDebug() << "updated baseUrl to" << d->baseUrl; + qCDebug(MAIN) << "updated baseUrl to" << d->baseUrl; } QString ConnectionData::lastEvent() const diff --git a/debug.cpp b/debug.cpp new file mode 100644 index 00000000..b80438e5 --- /dev/null +++ b/debug.cpp @@ -0,0 +1,30 @@ +/****************************************************************************** + * Copyright (C) 2017 Elvis Angelaccio <elvid.angelaccio@kde.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "util.h" + +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +Q_LOGGING_CATEGORY(MAIN, "libqmatrixclient.main", QtInfoMsg) +Q_LOGGING_CATEGORY(EVENTS, "libqmatrixclient.events", QtInfoMsg) +Q_LOGGING_CATEGORY(JOBS, "libqmatrixclient.jobs", QtInfoMsg) +#else +Q_LOGGING_CATEGORY(MAIN, "libqmatrixclient.main") +Q_LOGGING_CATEGORY(EVENTS, "libqmatrixclient.events") +Q_LOGGING_CATEGORY(JOBS, "libqmatrixclient.jobs") +#endif + 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 <QtCore/QJsonArray> #include <QtCore/QDebug> @@ -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 <QtCore/QJsonArray> #include <QtCore/QDebug> @@ -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 <QtCore/QDebug> @@ -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 <QtCore/QJsonArray> #include <QtCore/QDebug> @@ -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; } diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index 226290ff..3e2ecd54 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -17,6 +17,7 @@ */ #include "basejob.h" +#include "util.h" #include <array> @@ -86,13 +87,13 @@ BaseJob::BaseJob(ConnectionData* connection, HttpVerb verb, QString name, connect (&d->timer, &QTimer::timeout, this, &BaseJob::timeout); d->retryTimer.setSingleShot(true); connect (&d->retryTimer, &QTimer::timeout, this, &BaseJob::start); - qDebug() << this << "created"; + qCDebug(JOBS) << this << "created"; } BaseJob::~BaseJob() { stop(); - qDebug() << this << "destroyed"; + qCDebug(JOBS) << this << "destroyed"; } ConnectionData* BaseJob::connection() const @@ -174,7 +175,7 @@ void BaseJob::gotReply() BaseJob::Status BaseJob::checkReply(QNetworkReply* reply) const { if (reply->error() != QNetworkReply::NoError) - qDebug() << this << "returned" << reply->error(); + qCDebug(JOBS) << this << "returned" << reply->error(); switch( reply->error() ) { case QNetworkReply::NoError: @@ -217,11 +218,11 @@ void BaseJob::stop() d->timer.stop(); if (!d->reply) { - qWarning() << this << "stopped with empty network reply"; + qCWarning(JOBS) << this << "stopped with empty network reply"; } else if (d->reply->isRunning()) { - qWarning() << this << "stopped without ready network reply"; + qCWarning(JOBS) << this << "stopped without ready network reply"; d->reply->disconnect(this); // Ignore whatever comes from the reply d->reply->abort(); } @@ -235,7 +236,7 @@ void BaseJob::finishJob() { const auto retryInterval = getNextRetryInterval(); ++d->retriesTaken; - qWarning() << this << "will take retry" << d->retriesTaken + qCWarning(JOBS) << this << "will take retry" << d->retriesTaken << "in" << retryInterval/1000 << "s"; d->retryTimer.start(retryInterval); emit retryScheduled(d->retriesTaken, retryInterval); @@ -301,7 +302,7 @@ void BaseJob::setStatus(Status s) d->status = s; if (!s.good()) { - qWarning() << this << "status" << s.code << ":" << s.message; + qCWarning(JOBS) << this << "status" << s.code << ":" << s.message; } } @@ -324,7 +325,7 @@ void BaseJob::timeout() void BaseJob::sslErrors(const QList<QSslError>& errors) { foreach (const QSslError &error, errors) { - qWarning() << "SSL ERROR" << error.errorString(); + qCWarning(JOBS) << "SSL ERROR" << error.errorString(); } d->reply->ignoreSslErrors(); // TODO: insecure! should prompt user first } diff --git a/jobs/joinroomjob.cpp b/jobs/joinroomjob.cpp index a6f65c31..dce1f54e 100644 --- a/jobs/joinroomjob.cpp +++ b/jobs/joinroomjob.cpp @@ -17,6 +17,7 @@ */ #include "joinroomjob.h" +#include "util.h" #include <QtNetwork/QNetworkReply> @@ -56,6 +57,6 @@ BaseJob::Status JoinRoomJob::parseJson(const QJsonDocument& data) return Success; } - qDebug() << data; + qCDebug(JOBS) << data; return { UserDefinedError, "No room_id in the JSON response" }; } diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp index fdee8f47..cfde902a 100644 --- a/jobs/mediathumbnailjob.cpp +++ b/jobs/mediathumbnailjob.cpp @@ -17,6 +17,7 @@ */ #include "mediathumbnailjob.h" +#include "util.h" #include <QtCore/QDebug> @@ -55,7 +56,7 @@ BaseJob::Status MediaThumbnailJob::parseReply(QByteArray data) { if( !d->thumbnail.loadFromData(data) ) { - qDebug() << "MediaThumbnailJob: could not read image data"; + qCDebug(JOBS) << "MediaThumbnailJob: could not read image data"; } return Success; } diff --git a/jobs/postmessagejob.cpp b/jobs/postmessagejob.cpp index 69cc814d..9a102325 100644 --- a/jobs/postmessagejob.cpp +++ b/jobs/postmessagejob.cpp @@ -18,6 +18,7 @@ #include "postmessagejob.h" #include "../connectiondata.h" +#include "util.h" #include <QtNetwork/QNetworkReply> @@ -62,6 +63,6 @@ BaseJob::Status PostMessageJob::parseJson(const QJsonDocument& data) if( data.object().contains("event_id") ) return Success; - qDebug() << data; + qCDebug(JOBS) << data; return { UserDefinedError, "No event_id in the JSON response" }; } diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp index 6443217b..5779d695 100644 --- a/jobs/roommessagesjob.cpp +++ b/jobs/roommessagesjob.cpp @@ -43,7 +43,7 @@ RoomMessagesJob::RoomMessagesJob(ConnectionData* data, QString roomId, })) , d(new Private) { - qDebug() << "Room messages query:" << query().toString(QUrl::PrettyDecoded); + qCDebug(JOBS) << "Room messages query:" << query().toString(QUrl::PrettyDecoded); } RoomMessagesJob::~RoomMessagesJob() diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index b3724dff..8db1e2ca 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -123,7 +123,7 @@ SyncRoomData::SyncRoomData(QString roomId_, JoinState joinState_, const QJsonObj timeline.fromJson(room_); break; default: - qWarning() << "SyncRoomData: Unknown JoinState value, ignoring:" << int(joinState); + qCWarning(JOBS) << "SyncRoomData: Unknown JoinState value, ignoring:" << int(joinState); } QJsonObject timeline = room_.value("timeline").toObject(); @@ -133,5 +133,5 @@ SyncRoomData::SyncRoomData(QString roomId_, JoinState joinState_, const QJsonObj QJsonObject unread = room_.value("unread_notifications").toObject(); highlightCount = unread.value("highlight_count").toInt(); notificationCount = unread.value("notification_count").toInt(); - qDebug() << "Highlights: " << highlightCount << " Notifications:" << notificationCount; + qCDebug(JOBS) << "Highlights: " << highlightCount << " Notifications:" << notificationCount; } @@ -137,7 +137,7 @@ Room::Room(Connection* connection, QString id) // See "Accessing the Public Class" section in // https://marcmutz.wordpress.com/translated-articles/pimp-my-pimpl-%E2%80%94-reloaded/ d->q = this; - qDebug() << "New Room:" << id; + qCDebug(MAIN) << "New Room:" << id; //connection->getMembers(this); // I don't think we need this anymore in r0.0.1 } @@ -231,10 +231,10 @@ Room::Private::promoteReadMarker(User* u, Room::rev_iter_t newMarker) if (stillUnreadMessagesCount == 0) { unreadMessages = false; - qDebug() << "Room" << displayname << "has no more unread messages"; + qCDebug(MAIN) << "Room" << displayname << "has no more unread messages"; emit q->unreadMessagesChanged(q); } else - qDebug() << "Room" << displayname << "still has" + qCDebug(MAIN) << "Room" << displayname << "still has" << stillUnreadMessagesCount << "unread message(s)"; } @@ -248,7 +248,7 @@ void Room::markMessagesAsRead(Room::rev_iter_t upToMarker) User* localUser = connection()->user(); Private::rev_iter_pair_t markers = d->promoteReadMarker(localUser, upToMarker); if (markers.first != markers.second) - qDebug() << "Marked messages as read until" << *readMarker(); + qCDebug(MAIN) << "Marked messages as read until" << *readMarker(); // We shouldn't send read receipts for the local user's own messages - so // search earlier messages for the latest message not from the local user @@ -412,8 +412,8 @@ void Room::Private::insertEvent(Event* e, Timeline::iterator where, "Events can only be appended or prepended to the timeline"); if (eventsIndex.contains(e->id())) { - qWarning() << "Event" << e->id() << "is already in the timeline."; - qWarning() << "Either dropDuplicateEvents() wasn't called or duplicate " + qCWarning(MAIN) << "Event" << e->id() << "is already in the timeline."; + qCWarning(MAIN) << "Either dropDuplicateEvents() wasn't called or duplicate " "events within the same batch arrived from the server."; return; } @@ -447,7 +447,7 @@ void Room::Private::renameMember(User* u, QString oldName) { if (hasMember(u)) { - qWarning() << "Room::Private::renameMember(): the user " + qCWarning(MAIN) << "Room::Private::renameMember(): the user " << u->name() << "is already known in the room under a new name."; return; @@ -501,7 +501,7 @@ QString Room::roomMembername(User *u) const // room state ("room time machine"). // if ( !namesakes.contains(u) ) // { -// qWarning() +// qCWarning() // << "Room::roomMemberName(): user" << u->id() // << "is not a member of the room" << id(); // } @@ -613,7 +613,7 @@ void Room::doAddNewMessageEvents(const Events& events) d->appendEvent(e); newUnreadMessages += d->isEventNotable(e); } - qDebug() << "Room" << displayName() << "received" << events.size() + qCDebug(MAIN) << "Room" << displayName() << "received" << events.size() << "(with" << newUnreadMessages << "notable)" << "new events; the last event is now" << d->timeline.back(); @@ -626,7 +626,7 @@ void Room::doAddNewMessageEvents(const Events& events) if (readMarker(firstWriter) != timelineEdge()) { d->promoteReadMarker(firstWriter, findInTimeline(events.front()->id())); - qDebug() << "Auto-promoted read marker for" << firstWriter->id() + qCDebug(MAIN) << "Auto-promoted read marker for" << firstWriter->id() << "to" << *readMarker(firstWriter); } @@ -634,7 +634,7 @@ void Room::doAddNewMessageEvents(const Events& events) { d->unreadMessages = true; emit unreadMessagesChanged(this); - qDebug() << "Room" << displayName() << "has unread messages"; + qCDebug(MAIN) << "Room" << displayName() << "has unread messages"; } } @@ -654,7 +654,7 @@ void Room::doAddHistoricalMessageEvents(const Events& events) // Historical messages arrive in newest-to-oldest order for (auto e: events) d->prependEvent(e); - qDebug() << "Room" << displayName() << "received" << events.size() + qCDebug(MAIN) << "Room" << displayName() << "received" << events.size() << "past events; the oldest event is now" << d->timeline.front(); } @@ -666,7 +666,7 @@ void Room::processStateEvents(const Events& events) { RoomNameEvent* nameEvent = static_cast<RoomNameEvent*>(event); d->name = nameEvent->name(); - qDebug() << "room name:" << d->name; + qCDebug(MAIN) << "room name:" << d->name; d->updateDisplayname(); emit namesChanged(this); } @@ -674,7 +674,7 @@ void Room::processStateEvents(const Events& events) { RoomAliasesEvent* aliasesEvent = static_cast<RoomAliasesEvent*>(event); d->aliases = aliasesEvent->aliases(); - qDebug() << "room aliases:" << d->aliases; + qCDebug(MAIN) << "room aliases:" << d->aliases; // No displayname update - aliases are not used to render a displayname emit namesChanged(this); } @@ -682,7 +682,7 @@ void Room::processStateEvents(const Events& events) { RoomCanonicalAliasEvent* aliasEvent = static_cast<RoomCanonicalAliasEvent*>(event); d->canonicalAlias = aliasEvent->alias(); - qDebug() << "room canonical alias:" << d->canonicalAlias; + qCDebug(MAIN) << "room canonical alias:" << d->canonicalAlias; d->updateDisplayname(); emit namesChanged(this); } @@ -731,11 +731,10 @@ void Room::processEphemeralEvent(Event* event) const auto& eventId = eventReceiptPair.first; const auto& receipts = eventReceiptPair.second; { - auto qd = qDebug() << "Marking event" << eventId << "as read for"; if (receipts.size() == 1) - qd << receipts[0].userId; + qCDebug(MAIN) << "Marking event" << eventId << "as read for" << receipts[0].userId; else - qd << receipts.size() << "users"; + qCDebug(MAIN) << "Marking event" << eventId << "as read for" << receipts.size() << "users"; } if (d->eventsIndex.contains(eventId)) { @@ -745,7 +744,7 @@ void Room::processEphemeralEvent(Event* event) d->promoteReadMarker(m, newMarker); } else { - qDebug() << "Event" << eventId + qCDebug(MAIN) << "Event" << eventId << "not found; saving read markers anyway"; // If the event is not found (most likely, because it's too old // and hasn't been fetched from the server yet), but there is diff --git a/settings.cpp b/settings.cpp index 45af33e3..fbcd845f 100644 --- a/settings.cpp +++ b/settings.cpp @@ -10,7 +10,7 @@ Settings::~Settings() void Settings::setValue(const QString& key, const QVariant& value)
{
-// qDebug() << "Setting" << key << "to" << value;
+// qCDebug() << "Setting" << key << "to" << value;
QSettings::setValue(key, value);
}
@@ -22,6 +22,7 @@ #include "events/event.h" #include "events/roommemberevent.h" #include "jobs/mediathumbnailjob.h" +#include "util.h" #include <QtCore/QTimer> #include <QtCore/QDebug> @@ -97,7 +98,7 @@ QPixmap User::croppedAvatar(int width, int height) { if( !d->avatarOngoingRequest && d->avatarUrl.isValid() ) { - qDebug() << "Getting avatar for" << id(); + qCDebug(MAIN) << "Getting avatar for" << id(); d->requestedSize = size; d->avatarOngoingRequest = true; QTimer::singleShot(0, this, SLOT(requestAvatar())); @@ -18,7 +18,11 @@ #pragma once -#include <QtCore/QDebug> +#include <QtCore/QLoggingCategory> + +Q_DECLARE_LOGGING_CATEGORY(EVENTS) +Q_DECLARE_LOGGING_CATEGORY(JOBS) +Q_DECLARE_LOGGING_CATEGORY(MAIN) namespace QMatrixClient { @@ -35,7 +39,7 @@ namespace QMatrixClient * Together with the operator<<() helper, the proposed usage is * (similar to std:: I/O manipulators): * - * @example qDebug() << formatJson << json_object; // (QJsonObject, etc.) + * @example qCDebug() << formatJson << json_object; // (QJsonObject, etc.) */ inline QDebug formatJson(QDebug debug_object) { |