From 86e6013497f4c1db135e67106db2c8540cb8f690 Mon Sep 17 00:00:00 2001 From: APTX Date: Wed, 25 Dec 2019 22:37:49 +0900 Subject: [PATCH] Add extra debug logs option to cmake --- CMakeLists.txt | 8 ++++++++ client.cpp | 9 +++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d2c1c2..115014e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ add_feature_info(RenameParser WITH_RENAMEPARSER "file renaming engine") option(WITH_ENCRYPTION "Enable encryption" ON) add_feature_info(Encryption WITH_ENCRYPTION "ENCRYPT command support (requires QCA)") +option(WITH_CLIENT_DEBUG "Enable client debug logs" ON) +add_feature_info(ClientDebug WITH_CLIENT_DEBUG "Print extra logs for debug purposes") + set(QT_MIN_VERSION "5.8.0") find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core @@ -186,6 +189,11 @@ if (NOT WITH_ENCRYPTION) add_definitions(-DANIDBUDPCLIENT_NO_ENCRYPT) endif() +if (WITH_CLIENT_DEBUG) + add_definitions(-DANIDBUDPCLIENT_CLIENT_MISC_DEBUG) + add_definitions(-DANIDBUDPCLIENT_CLIENT_COMMAND_DEBUG) +endif() + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) diff --git a/client.cpp b/client.cpp index 52fa317..3eb994d 100644 --- a/client.cpp +++ b/client.cpp @@ -725,9 +725,6 @@ qDebug() << QString("Sending reply to command with id: %1") { // If we got the first command sent, we update the replyTimeoutTimer to count the remaining time untill timeout. resetReplyTimeoutTimer(sentCommands[sentCommandOrder.head()]); -#ifdef ANIDBUDPCLIENT_CLIENT_MISC_DEBUG -qDebug() << "Starting replyTimeoutTimer" << newTimeout; -#endif } } else @@ -1099,6 +1096,9 @@ void Client::resetReplyTimeoutTimer(AbstractReply *cmd) int newTimeout = qBound(qint64(0), qint64(Client::UDP_API_COMMAND_TIMEOUT - cmd->timeSent().secsTo(QDateTime::currentDateTime())), qint64(Client::UDP_API_COMMAND_TIMEOUT)); newTimeout *= 1000; replyTimeoutTimer->start(newTimeout); +#ifdef ANIDBUDPCLIENT_CLIENT_MISC_DEBUG +qDebug() << "Starting replyTimeoutTimer" << newTimeout; +#endif } void Client::init() @@ -1124,9 +1124,6 @@ qDebug() << commandId << "timed out"; if (!sentCommandOrder.isEmpty()) { resetReplyTimeoutTimer(sentCommands[sentCommandOrder.head()]); -#ifdef ANIDBUDPCLIENT_CLIENT_MISC_DEBUG -qDebug() << "Starting replyTimeoutTimer" << newTimeout; -#endif } // If it's empty thereis no need to start replyTimeoutTimer again, as there are no commands waiting. -- 2.52.0