diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/connection.cpp | 4 | ||||
-rw-r--r-- | lib/logging.h | 31 | ||||
-rw-r--r-- | lib/quotient_common.cpp | 45 | ||||
-rw-r--r-- | lib/quotient_common.h | 6 | ||||
-rw-r--r-- | lib/room.cpp | 4 |
6 files changed, 26 insertions, 66 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 34200548..3814bc7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ endif () # Set up source files list(APPEND lib_SRCS - lib/quotient_common.cpp + lib/quotient_common.h lib/networkaccessmanager.cpp lib/connectiondata.cpp lib/connection.cpp diff --git a/lib/connection.cpp b/lib/connection.cpp index 75966731..e65fdac4 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -636,7 +636,7 @@ void Connection::Private::consumeRoomData(SyncDataList&& roomDataList, } qWarning(MAIN) << "Room" << roomData.roomId << "has just been forgotten but /sync returned it in" - << roomData.joinState + << terse << roomData.joinState << "state - suspiciously fast turnaround"; } if (auto* r = q->provideRoom(roomData.roomId, roomData.joinState)) { @@ -1341,7 +1341,7 @@ void Connection::Private::removeRoom(const QString& roomId) { for (auto f : { false, true }) if (auto r = roomMap.take({ roomId, f })) { - qCDebug(MAIN) << "Room" << r->objectName() << "in state" + qCDebug(MAIN) << "Room" << r->objectName() << "in state" << terse << r->joinState() << "will be deleted"; emit r->beforeDestruction(r); r->deleteLater(); diff --git a/lib/logging.h b/lib/logging.h index 5a3ef6ea..5bf050a9 100644 --- a/lib/logging.h +++ b/lib/logging.h @@ -40,17 +40,15 @@ inline QDebug formatJson(QDebug debug_object) return debug_object.noquote(); } -/** - * @brief A helper operator to facilitate usage of formatJson (and possibly - * other manipulators) - * - * @param debug_object to output the json to - * @param qdm a QDebug manipulator - * @return a copy of debug_object that has its mode altered by qdm - */ -inline QDebug operator<<(QDebug debug_object, QDebugManip qdm) +//! Suppress full qualification of enums/QFlags when logging +inline QDebug terse(QDebug dbg) { - return qdm(debug_object); + return +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) + dbg.setVerbosity(0), dbg; +#else + dbg.verbosity(QDebug::MinimumVerbosity); +#endif } inline qint64 profilerMinNsecs() @@ -65,6 +63,19 @@ inline qint64 profilerMinNsecs() } } // namespace Quotient +/** + * @brief A helper operator to facilitate usage of formatJson (and possibly + * other manipulators) + * + * @param debug_object to output the json to + * @param qdm a QDebug manipulator + * @return a copy of debug_object that has its mode altered by qdm + */ +inline QDebug operator<<(QDebug debug_object, Quotient::QDebugManip qdm) +{ + return qdm(debug_object); +} + inline QDebug operator<<(QDebug debug_object, const QElapsedTimer& et) { auto val = et.nsecsElapsed() / 1000; diff --git a/lib/quotient_common.cpp b/lib/quotient_common.cpp deleted file mode 100644 index 5d7a3027..00000000 --- a/lib/quotient_common.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "quotient_common.h" - -#include <QtCore/QDebug> - -using namespace Quotient; - -template <typename Enum> -inline QDebug suppressScopeAndDump(QDebug dbg, Enum e) -{ - // Suppress "Quotient::" prefix - QDebugStateSaver _dss(dbg); - dbg.setVerbosity(0 /* QDebug::MinimumVerbosity since Qt 5.13 */); - return qt_QMetaEnum_debugOperator(dbg, std::underlying_type_t<Enum>(e), - qt_getEnumMetaObject(e), - qt_getEnumName(e)); -} - -template <typename Enum> -inline QDebug suppressScopeAndDump(QDebug dbg, const QFlags<Enum>& f) -{ - // Suppress "Quotient::" prefix - QDebugStateSaver _dss(dbg); - dbg.setVerbosity(0 /* QDebug::MinimumVerbosity since Qt 5.13 */); - return qt_QMetaEnum_flagDebugOperator_helper(dbg, f); -} - -QDebug operator<<(QDebug dbg, Membership m) -{ - return suppressScopeAndDump(dbg, m); -} - -QDebug operator<<(QDebug dbg, MembershipMask mm) -{ - return suppressScopeAndDump(dbg, mm) << ")"; -} - -QDebug operator<<(QDebug dbg, JoinState js) -{ - return suppressScopeAndDump(dbg, js); -} - -QDebug operator<<(QDebug dbg, JoinStates jss) -{ - return suppressScopeAndDump(dbg, jss) << ")"; -} diff --git a/lib/quotient_common.h b/lib/quotient_common.h index 3d8ace67..969ebe90 100644 --- a/lib/quotient_common.h +++ b/lib/quotient_common.h @@ -118,9 +118,3 @@ constexpr inline auto RoomTypeStrings = make_array( } // namespace Quotient Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::MembershipMask) Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::JoinStates) - -class QDebug; -QDebug operator<<(QDebug dbg, Quotient::Membership m); -QDebug operator<<(QDebug dbg, Quotient::MembershipMask m); -QDebug operator<<(QDebug dbg, Quotient::JoinState js); -QDebug operator<<(QDebug dbg, Quotient::JoinStates js); diff --git a/lib/room.cpp b/lib/room.cpp index a376238e..a2ec228a 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -461,7 +461,7 @@ Room::Room(Connection* connection, QString id, JoinState initialJoinState) emit baseStateLoaded(); return this == r; // loadedRoomState fires only once per room }); - qCDebug(STATE) << "New" << initialJoinState << "Room:" << id; + qCDebug(STATE) << "New" << terse << initialJoinState << "Room:" << id; } Room::~Room() { delete d; } @@ -612,7 +612,7 @@ void Room::setJoinState(JoinState state) if (state == oldState) return; d->joinState = state; - qCDebug(STATE) << "Room" << id() << "changed state: " << oldState + qCDebug(STATE) << "Room" << id() << "changed state: " << terse << oldState << "->" << state; emit joinStateChanged(oldState, state); } |