From 42ca658ff779cfcbde8b4d21c924c628d308e553 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 15 Mar 2022 13:51:53 +0100 Subject: [PATCH] Fix debug category for cloud transport --- libnymea-app/connection/cloudtransport.cpp | 25 ++++++++++++---------- libnymea-app/jsonrpc/jsonrpcclient.cpp | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libnymea-app/connection/cloudtransport.cpp b/libnymea-app/connection/cloudtransport.cpp index 7820a2bf..1751748f 100644 --- a/libnymea-app/connection/cloudtransport.cpp +++ b/libnymea-app/connection/cloudtransport.cpp @@ -38,6 +38,9 @@ #include #include +#include +Q_DECLARE_LOGGING_CATEGORY(dcCloud) + using namespace remoteproxyclient; CloudTransport::CloudTransport(AWSClient *awsClient, QObject *parent): @@ -47,27 +50,27 @@ CloudTransport::CloudTransport(AWSClient *awsClient, QObject *parent): m_remoteproxyConnection = new RemoteProxyConnection(QUuid::createUuid(), qApp->applicationName(), this); QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::remoteConnectionEstablished, this,[this]() { - qDebug() << "CloudTransport: Remote connection established."; + qCDebug(dcCloud) << "CloudTransport: Remote connection established."; emit connected(); }); QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::disconnected, this,[this]() { - qDebug() << "CloudTransport: Disconnected."; + qCDebug(dcCloud) << "CloudTransport: Disconnected."; emit disconnected(); }); QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::stateChanged, this,[](RemoteProxyConnection::State state) { - qDebug() << "Proxy state changed:" << state; + qCDebug(dcCloud) << "Proxy state changed:" << state; }); QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::ready, this,[this]() { - qDebug() << "Proxy ready. Authenticating channel."; + qCDebug(dcCloud) << "Proxy ready. Authenticating channel."; m_remoteproxyConnection->authenticate(m_awsClient->idToken(), m_nonce); }); QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::dataReady, this, [this](const QByteArray &data) { emit dataReady(data); }); QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::errorOccurred, this, [] (QAbstractSocket::SocketError error) { - qDebug() << "Remote proxy Error:" << error; + qCDebug(dcCloud) << "Remote proxy Error:" << error; // emit NymeaTransportInterface::error(QAbstractSocket::ConnectionRefusedError); }); QObject::connect(m_remoteproxyConnection, &RemoteProxyConnection::sslErrors, this, &CloudTransport::sslErrors); @@ -80,16 +83,16 @@ bool CloudTransport::connect(const QUrl &url) return false; } - qDebug() << "Connecting to" << url; + qCDebug(dcCloud) << "Connecting to" << url; m_url = url; m_nonce = QUuid::createUuid().toString(); bool postResult = m_awsClient->postToMQTT(url.host(), m_nonce, QPointer(this), [this](bool success) { if (success) { - qDebug() << "MQTT Post done. Connecting to remote proxy"; + qCDebug(dcCloud) << "MQTT Post done. Connecting to remote proxy"; m_remoteproxyConnection->connectServer(QUrl("wss://remoteproxy.nymea.io")); } else { - qDebug() << "Posting to MQTT failed"; + qCDebug(dcCloud) << "Posting to MQTT failed"; emit error(QAbstractSocket::HostNotFoundError); } }); @@ -109,7 +112,7 @@ QUrl CloudTransport::url() const void CloudTransport::disconnect() { - qDebug() << "CloudTransport: Disconnecting from server."; + qCDebug(dcCloud) << "CloudTransport: Disconnecting from server."; m_remoteproxyConnection->disconnectServer(); } @@ -135,13 +138,13 @@ NymeaTransportInterface::ConnectionState CloudTransport::connectionState() const void CloudTransport::sendData(const QByteArray &data) { -// qDebug() << "Cloud transport: Sending data:" << data; +// qCDebug(dcCloud) << "Cloud transport: Sending data:" << data; m_remoteproxyConnection->sendData(data); } void CloudTransport::ignoreSslErrors(const QList &errors) { - qDebug() << "CloudTransport: Ignoring SSL errors" << errors; + qCDebug(dcCloud) << "CloudTransport: Ignoring SSL errors" << errors; m_remoteproxyConnection->ignoreSslErrors(errors); } diff --git a/libnymea-app/jsonrpc/jsonrpcclient.cpp b/libnymea-app/jsonrpc/jsonrpcclient.cpp index 0ba19841..028881bc 100644 --- a/libnymea-app/jsonrpc/jsonrpcclient.cpp +++ b/libnymea-app/jsonrpc/jsonrpcclient.cpp @@ -521,6 +521,7 @@ void JsonRpcClient::setNotificationsEnabled() } JsonRpcReply *reply = createReply("JSONRPC.SetNotificationStatus", params, this, "setNotificationsEnabledResponse"); m_replies.insert(reply->commandId(), reply); + qCDebug(dcJsonRpc) << "Setting notification status"; sendRequest(reply->requestMap()); }