]> Some of my projects - anidbudpclient.git/commitdiff
Add extra debug logs option to cmake
authorAPTX <marek321@gmail.com>
Wed, 25 Dec 2019 13:37:49 +0000 (22:37 +0900)
committerAPTX <marek321@gmail.com>
Wed, 25 Dec 2019 13:37:49 +0000 (22:37 +0900)
CMakeLists.txt
client.cpp

index 3d2c1c275475419e17ecd2d69280f289c0114541..115014efaa36a67a0c651fb0b02c7f14500ae60a 100644 (file)
@@ -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)
index 52fa317b4caf2a59bea06a70cf1df212f668f72e..3eb994d927721de678604028d43b5448d4b75d6e 100644 (file)
@@ -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.