Skip to content

Commit 0414770

Browse files
committed
Log Qt debug messages
1 parent 8c6f973 commit 0414770

7 files changed

Lines changed: 39 additions & 4 deletions

File tree

src/cloud/doc/RELEASE_NOTES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
Version 1.0.2
33

44
- Improved HTTP server thread safety, timeout handling, and resource cleanup
5+
- Added certificate expiry validation to RHttpServer and RHttpClient
56
- Added script to renew expired certificate for local accounts
7+
- Log Qt debug messages
68

79
------------------------------------------------------------------
810
Version 1.0.1

src/cloud/scripts/cloud_start.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Usage: $myName.sh [OPTION]...
3232
3333
--log-debug Switch on debug log level
3434
--log-trace Switch on trace log level
35+
--log-ssl Switch on ssl debug log level
36+
--log-qt Switch on qt debug log level
3537
3638
--help, -h, -? Print this help and exit
3739
@@ -44,7 +46,7 @@ do
4446
--interactive)
4547
runInteractive="true"
4648
;;
47-
--log-debug | --log-trace)
49+
--log-debug | --log-trace | --log-ssl | --log-qt)
4850
additionalParameters+=" $1"
4951
;;
5052
--help | -h | -?)

src/cloud/src/application.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <locale.h>
33

44
#include <QDir>
5+
#include <QLoggingCategory>
56
#include <QTimer>
67
#include <QSettings>
78
#include <QStandardPaths>
@@ -23,6 +24,8 @@ const QString Application::cloudDirectoryKey = "cloud-directory";
2324
const QString Application::rangeCaDirectoryKey = "range-ca-directory";
2425
const QString Application::logDebugKey = "log-debug";
2526
const QString Application::logTraceKey = "log-trace";
27+
const QString Application::logQtKey = "log-qt";
28+
const QString Application::logSslKey = "log-ssl";
2629
const QString Application::publicHttpPortKey = "public-http-port";
2730
const QString Application::privateHttpPortKey = "private-http-port";
2831
const QString Application::publicKeyKey = "public-key";
@@ -151,6 +154,8 @@ void Application::onStarted()
151154

152155
validOptions.append(RArgumentOption(Application::logDebugKey,RArgumentOption::Switch,QVariant(),"Switch on debug log level",RArgumentOption::Logger,false));
153156
validOptions.append(RArgumentOption(Application::logTraceKey,RArgumentOption::Switch,QVariant(),"Switch on trace log level",RArgumentOption::Logger,false));
157+
validOptions.append(RArgumentOption(Application::logQtKey,RArgumentOption::Switch,QVariant(),"Route Qt debug messages through RLogger",RArgumentOption::Logger,false));
158+
validOptions.append(RArgumentOption(Application::logSslKey,RArgumentOption::Switch,QVariant(),"Enable Qt SSL debug logging",RArgumentOption::Logger,false));
154159

155160
validOptions.append(RArgumentOption(Application::publicHttpPortKey,RArgumentOption::Integer,Configuration::getDefaultPublicHttpPort(),"Public HTTP Server port",RArgumentOption::Optional,false));
156161
validOptions.append(RArgumentOption(Application::privateHttpPortKey,RArgumentOption::Integer,Configuration::getDefaultPrivateHttpPort(),"Private HTTP Server port",RArgumentOption::Optional,false));
@@ -177,6 +182,30 @@ void Application::onStarted()
177182
{
178183
RLogger::getInstance().setLevel(R_LOG_LEVEL_TRACE);
179184
}
185+
if (argumentsParser.isSet(Application::logQtKey) ||
186+
argumentsParser.isSet(Application::logSslKey))
187+
{
188+
RLogger::installQtMessageHandler();
189+
RLogger::debug("Qt message handler installed\n");
190+
191+
if (argumentsParser.isSet(Application::logQtKey))
192+
{
193+
QLoggingCategory::setFilterRules("qt.*=true");
194+
RLogger::debug("All Qt logging enabled\n");
195+
}
196+
else if (argumentsParser.isSet(Application::logSslKey))
197+
{
198+
QLoggingCategory::setFilterRules(
199+
"qt.network.ssl.debug=true\n"
200+
"qt.network.ssl.info=true\n"
201+
"qt.network.ssl.warning=true\n"
202+
"qt.tlsbackend.ossl.debug=true\n"
203+
"qt.tlsbackend.ossl.info=true\n"
204+
"qt.tlsbackend.ossl.warning=true"
205+
);
206+
RLogger::debug("SSL logging enabled\n");
207+
}
208+
}
180209

181210
if (argumentsParser.isSet("help"))
182211
{

src/cloud/src/application.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class Application : public QCoreApplication
2424
static const QString rangeCaDirectoryKey;
2525
static const QString logDebugKey;
2626
static const QString logTraceKey;
27+
static const QString logQtKey;
28+
static const QString logSslKey;
2729
static const QString publicHttpPortKey;
2830
static const QString privateHttpPortKey;
2931
static const QString publicKeyKey;

0 commit comments

Comments
 (0)