diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-08-18 19:06:06 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-08-18 19:28:29 +0900 |
commit | aa004bd80f9548c00bd7856c20421f168fadad69 (patch) | |
tree | cc5517e4425afca7bd332506ebc42abd5f4b6b86 /lib/room.cpp | |
parent | a9eef2c6b2f73ebc921b07fe37009bccf31038c8 (diff) | |
download | libquotient-aa004bd80f9548c00bd7856c20421f168fadad69.tar.gz libquotient-aa004bd80f9548c00bd7856c20421f168fadad69.zip |
Room: use new logging categories
Diffstat (limited to 'lib/room.cpp')
-rw-r--r-- | lib/room.cpp | 97 |
1 files changed, 51 insertions, 46 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index f7d3a797..cd7aaac7 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -215,8 +215,8 @@ public: stubbedState.emplace(evtKey, loadStateEvent(EventT::matrixTypeId(), {}, stateKey)); - qCDebug(MAIN) << "A new stub event created for key {" - << evtKey.first << evtKey.second << "}"; + qCDebug(STATE) << "A new stub event created for key {" + << evtKey.first << evtKey.second << "}"; } evt = stubbedState[evtKey].get(); Q_ASSERT(evt); @@ -475,8 +475,8 @@ void Room::setJoinState(JoinState state) if (state == oldState) return; d->joinState = state; - qCDebug(MAIN) << "Room" << id() << "changed state: " << int(oldState) - << "->" << int(state); + qCDebug(STATE) << "Room" << id() << "changed state: " << int(oldState) + << "->" << int(state); emit changed(Change::JoinStateChange); emit joinStateChanged(oldState, state); } @@ -530,12 +530,12 @@ void Room::Private::updateUnreadCount(rev_iter_t from, rev_iter_t to) unreadMessages = 0; unreadMessages += newUnreadMessages; - qCDebug(MAIN) << "Room" << q->objectName() << "has gained" - << newUnreadMessages << "unread message(s)," - << (q->readMarker() == timeline.crend() - ? "in total at least" - : "in total") - << unreadMessages << "unread message(s)"; + qCDebug(MESSAGES) << "Room" << q->objectName() << "has gained" + << newUnreadMessages << "unread message(s)," + << (q->readMarker() == timeline.crend() + ? "in total at least" + : "in total") + << unreadMessages << "unread message(s)"; emit q->unreadMessagesChanged(q); } } @@ -577,11 +577,11 @@ Room::Changes Room::Private::promoteReadMarker(User* u, rev_iter_t newMarker, if (force || unreadMessages != oldUnreadCount) { if (unreadMessages == -1) { - qCDebug(MAIN) + qCDebug(MESSAGES) << "Room" << displayname << "has no more unread messages"; } else - qCDebug(MAIN) << "Room" << displayname << "still has" - << unreadMessages << "unread message(s)"; + qCDebug(MESSAGES) << "Room" << displayname << "still has" + << unreadMessages << "unread message(s)"; emit q->unreadMessagesChanged(q); changes |= Change::UnreadNotifsChange; } @@ -594,7 +594,7 @@ Room::Changes Room::Private::markMessagesAsRead(rev_iter_t upToMarker) const auto prevMarker = q->readMarker(); auto changes = promoteReadMarker(q->localUser(), upToMarker); if (prevMarker != upToMarker) - qCDebug(MAIN) << "Marked messages as read until" << *q->readMarker(); + qCDebug(MESSAGES) << "Marked messages as read until" << *q->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 @@ -940,10 +940,10 @@ void Room::Private::setTags(TagsMap newTags) else newTags.insert(checkRes.second, newTags.take(k)); } - } + tags = move(newTags); - qCDebug(MAIN) << "Room" << q->objectName() << "is tagged with" - << q->tagNames().join(QStringLiteral(", ")); + qCDebug(STATE) << "Room" << q->objectName() << "is tagged with" + << q->tagNames().join(QStringLiteral(", ")); emit q->tagsChanged(); } @@ -1381,7 +1381,7 @@ void Room::updateData(SyncRoomData&& data, bool fromCache) // See https://github.com/quotient-im/libQuotient/wiki/unread_count if (data.unreadCount != -2 && data.unreadCount != d->unreadMessages) { - qCDebug(MAIN) << "Setting unread_count to" << data.unreadCount; + qCDebug(MESSAGES) << "Setting unread_count to" << data.unreadCount; d->unreadMessages = data.unreadCount; roomChanges |= Change::UnreadNotifsChange; emit unreadMessagesChanged(this); @@ -1495,12 +1495,13 @@ QString Room::retryMessage(const QString& txnId) if (transferIt != d->fileTransfers.end()) { Q_ASSERT(transferIt->isUpload); if (transferIt->status == FileTransferInfo::Completed) { - qCDebug(MAIN) << "File for transaction" << txnId - << "has already been uploaded, bypassing re-upload"; + qCDebug(MESSAGES) + << "File for transaction" << txnId + << "has already been uploaded, bypassing re-upload"; } else { if (isJobRunning(transferIt->job)) { - qCDebug(MAIN) << "Abandoning the upload job for transaction" - << txnId << "and starting again"; + qCDebug(MESSAGES) << "Abandoning the upload job for transaction" + << txnId << "and starting again"; transferIt->job->abandon(); emit fileTransferFailed(txnId, tr("File upload will be retried")); @@ -1996,15 +1997,15 @@ bool Room::Private::processRedaction(const RedactionEvent& redaction) auto& ti = timeline[Timeline::size_type(*pIdx - q->minTimelineIndex())]; if (ti->isRedacted() && ti->redactedBecause()->id() == redaction.id()) { - qCDebug(MAIN) << "Redaction" << redaction.id() << "of event" << ti->id() - << "already done, skipping"; + qCDebug(EVENTS) << "Redaction" << redaction.id() << "of event" + << ti->id() << "already done, skipping"; return true; } // Make a new event from the redacted JSON and put it in the timeline // instead of the redacted one. oldEvent will be deleted on return. auto oldEvent = ti.replaceEvent(makeRedacted(*ti, redaction)); - qCDebug(MAIN) << "Redacted" << oldEvent->id() << "with" << redaction.id(); + qCDebug(EVENTS) << "Redacted" << oldEvent->id() << "with" << redaction.id(); if (oldEvent->isStateEvent()) { const StateEventKey evtKey { oldEvent->matrixType(), oldEvent->stateKey() }; @@ -2012,7 +2013,7 @@ bool Room::Private::processRedaction(const RedactionEvent& redaction) if (currentState.value(evtKey) == oldEvent.get()) { Q_ASSERT(ti.index() >= 0); // Historical states can't be in // currentState - qCDebug(MAIN).nospace() + qCDebug(EVENTS).nospace() << "Redacting state " << oldEvent->matrixType() << "/" << oldEvent->stateKey(); // Retarget the current state to the newly made event. @@ -2066,7 +2067,7 @@ bool Room::Private::processReplacement(const RoomMessageEvent& newEvent) auto& ti = timeline[Timeline::size_type(*pIdx - q->minTimelineIndex())]; if (ti->replacedBy() == newEvent.id()) { - qCDebug(MAIN) << "Event" << ti->id() << "is already replaced with" + qCDebug(EVENTS) << "Event" << ti->id() << "is already replaced with" << newEvent.id(); return true; } @@ -2074,7 +2075,7 @@ bool Room::Private::processReplacement(const RoomMessageEvent& newEvent) // Make a new event from the redacted JSON and put it in the timeline // instead of the redacted one. oldEvent will be deleted on return. auto oldEvent = ti.replaceEvent(makeReplaced(*ti, newEvent)); - qCDebug(MAIN) << "Replaced" << oldEvent->id() << "with" << newEvent.id(); + qCDebug(EVENTS) << "Replaced" << oldEvent->id() << "with" << newEvent.id(); emit q->replacedEvent(ti.event(), rawPtr(oldEvent)); return true; } @@ -2125,7 +2126,7 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events) if (targetIt != it) *targetIt = makeRedacted(**targetIt, *r); else - qCDebug(MAIN) + qCDebug(EVENTS) << "Redaction" << r->id() << "ignored: target event" << r->redactedEvent() << "is not found"; // If the target event comes later, it comes already redacted. @@ -2142,9 +2143,10 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events) if (targetIt != it) *targetIt = makeReplaced(**targetIt, *msg); else // FIXME: don't ignore, just show it wherever it arrived - qCDebug(MAIN) << "Replacing event" << msg->id() - << "ignored: replaced event" - << msg->replacedEvent() << "is not found"; + qCDebug(EVENTS) + << "Replacing event" << msg->id() + << "ignored: replaced event" << msg->replacedEvent() + << "is not found"; // Same as with redactions above, the replaced event coming // later will come already with the new content. } @@ -2191,9 +2193,9 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events) emit q->pendingEventChanged(pendingEvtIdx); } emit q->pendingEventAboutToMerge(nextPendingEvt, pendingEvtIdx); - qDebug(EVENTS) << "Merging pending event from transaction" - << nextPendingEvt->transactionId() << "into" - << nextPendingEvt->id(); + qDebug(MESSAGES) << "Merging pending event from transaction" + << nextPendingEvt->transactionId() << "into" + << nextPendingEvt->id(); auto transfer = fileTransfers.take(nextPendingEvt->transactionId()); if (transfer.status != FileTransferInfo::None) fileTransfers.insert(nextPendingEvt->id(), transfer); @@ -2226,8 +2228,9 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events) } } - qCDebug(MAIN) << "Room" << q->objectName() << "received" << totalInserted - << "new events; the last event is now" << timeline.back(); + qCDebug(MESSAGES) << "Room" << q->objectName() << "received" + << totalInserted << "new events; the last event is now" + << timeline.back(); // The first event in the just-added batch (referred to by `from`) // defines whose read marker can possibly be promoted any further over @@ -2238,8 +2241,9 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events) auto firstWriter = q->user((*from)->senderId()); if (q->readMarker(firstWriter) != timeline.crend()) { roomChanges |= promoteReadMarker(firstWriter, rev_iter_t(from) - 1); - qCDebug(MAIN) << "Auto-promoted read marker for" << firstWriter->id() - << "to" << *q->readMarker(firstWriter); + qCDebug(MESSAGES) + << "Auto-promoted read marker for" << firstWriter->id() << "to" + << *q->readMarker(firstWriter); } updateUnreadCount(timeline.crbegin(), rev_iter_t(from)); @@ -2276,8 +2280,9 @@ void Room::Private::addHistoricalMessageEvents(RoomEvents&& events) const auto insertedSize = moveEventsToTimeline(events, Older); const auto from = timeline.crend() - insertedSize; - qCDebug(MAIN) << "Room" << displayname << "received" << insertedSize - << "past events; the oldest event is now" << timeline.front(); + qCDebug(MESSAGES) << "Room" << displayname << "received" << insertedSize + << "past events; the oldest event is now" + << timeline.front(); q->onAddHistoricalTimelineEvents(from); emit q->addedMessages(timeline.front().index(), from->index()); @@ -2319,13 +2324,13 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) , [this,oldStateEvent] (const RoomAliasesEvent& ae) { // clang-format on if (ae.aliases().isEmpty()) { - qDebug(MAIN).noquote() + qDebug(STATE).noquote() << ae.stateKey() << "no more has aliases for room" << objectName(); d->aliasServers.remove(ae.stateKey()); } else { d->aliasServers.insert(ae.stateKey()); - qDebug(MAIN).nospace().noquote() + qDebug(STATE).nospace().noquote() << "New server with aliases for room " << objectName() << ": " << ae.stateKey(); } @@ -2372,7 +2377,7 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) break; case MembershipType::Join: if (evt.membership() == MembershipType::Invite) - qCWarning(MAIN) << "Invalid membership change from " + qCWarning(STATE) << "Invalid membership change from " "Join to Invite:" << evt; if (evt.membership() != prevMembership) { @@ -2519,7 +2524,7 @@ Room::Changes Room::processAccountDataEvent(EventPtr&& event) if (auto* evt = eventCast<ReadMarkerEvent>(event)) { auto readEventId = evt->event_id(); - qCDebug(MAIN) << "Server-side read marker at" << readEventId; + qCDebug(STATE) << "Server-side read marker at" << readEventId; d->serverReadMarker = readEventId; const auto newMarker = findInTimeline(readEventId); changes |= newMarker != timelineEdge() @@ -2533,7 +2538,7 @@ Room::Changes Room::processAccountDataEvent(EventPtr&& event) if (!currentData || currentData->contentJson() != event->contentJson()) { emit accountDataAboutToChange(event->matrixType()); currentData = move(event); - qCDebug(MAIN) << "Updated account data of type" + qCDebug(STATE) << "Updated account data of type" << currentData->matrixType(); emit accountDataChanged(currentData->matrixType()); return Change::AccountDataChange; |