From f2b1ed4288e9cb4bc9e947f129ef06a9d9b5243a Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sun, 2 Feb 2025 15:45:12 -0800 Subject: [PATCH] add logging category for remote_client --- cockatrice/resources/config/qtlogging.ini | 2 ++ cockatrice/src/server/remote/remote_client.cpp | 14 +++++++------- cockatrice/src/server/remote/remote_client.h | 3 +++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cockatrice/resources/config/qtlogging.ini b/cockatrice/resources/config/qtlogging.ini index ca68708fd..6e991124d 100644 --- a/cockatrice/resources/config/qtlogging.ini +++ b/cockatrice/resources/config/qtlogging.ini @@ -23,6 +23,8 @@ # servers_settings = false # shortcuts_settings = false +# remote_client = false + # player = false # game_scene = false # game_scene.player_addition_removal = false diff --git a/cockatrice/src/server/remote/remote_client.cpp b/cockatrice/src/server/remote/remote_client.cpp index 282f45e68..329e31099 100644 --- a/cockatrice/src/server/remote/remote_client.cpp +++ b/cockatrice/src/server/remote/remote_client.cpp @@ -140,7 +140,7 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica hashedPassword = PasswordHasher::computeHash(password, passwordSalt); cmdForgotPasswordReset.set_hashed_new_password(hashedPassword.toStdString()); } else if (!password.isEmpty()) { - qWarning() << "using plain text password to reset password"; + qCWarning(RemoteClientLog) << "using plain text password to reset password"; cmdForgotPasswordReset.set_new_password(password.toStdString()); } PendingCommand *pend = prepareSessionCommand(cmdForgotPasswordReset); @@ -170,7 +170,7 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica hashedPassword = PasswordHasher::computeHash(password, passwordSalt); cmdRegister.set_hashed_password(hashedPassword.toStdString()); } else if (!password.isEmpty()) { - qWarning() << "using plain text password to register"; + qCWarning(RemoteClientLog) << "using plain text password to register"; cmdRegister.set_password(password.toStdString()); } cmdRegister.set_email(email.toStdString()); @@ -241,7 +241,7 @@ void RemoteClient::doLogin() setStatus(StatusLoggingIn); Command_Login cmdLogin = generateCommandLogin(); if (!password.isEmpty()) { - qWarning() << "using plain text password to log in"; + qCWarning(RemoteClientLog) << "using plain text password to log in"; cmdLogin.set_password(password.toStdString()); } @@ -394,7 +394,7 @@ void RemoteClient::readData() ServerMessage newServerMessage; newServerMessage.ParseFromArray(inputBuffer.data(), messageLength); #ifdef QT_DEBUG - qDebug().noquote() << "IN" << getSafeDebugString(newServerMessage); + qCDebug(RemoteClientLog).noquote() << "IN" << getSafeDebugString(newServerMessage); #endif inputBuffer.remove(0, messageLength); messageInProgress = false; @@ -412,7 +412,7 @@ void RemoteClient::websocketMessageReceived(const QByteArray &message) ServerMessage newServerMessage; newServerMessage.ParseFromArray(message.data(), message.length()); #ifdef QT_DEBUG - qDebug().noquote() << "IN" << getSafeDebugString(newServerMessage); + qCDebug(RemoteClientLog).noquote() << "IN" << getSafeDebugString(newServerMessage); #endif processProtocolItem(newServerMessage); } @@ -425,7 +425,7 @@ void RemoteClient::sendCommandContainer(const CommandContainer &cont) auto size = static_cast(cont.ByteSize()); #endif #ifdef QT_DEBUG - qDebug().noquote() << "OUT" << getSafeDebugString(cont); + qCDebug(RemoteClientLog).noquote() << "OUT" << getSafeDebugString(cont); #endif QByteArray buf; @@ -590,7 +590,7 @@ QString RemoteClient::getSrvClientID(const QString &_hostname) QHostAddress hostAddress = hostInfo.addresses().first(); srvClientID += hostAddress.toString(); } else { - qWarning() << "ClientID generation host lookup failure [" << hostInfo.errorString() << "]"; + qCWarning(RemoteClientLog) << "ClientID generation host lookup failure [" << hostInfo.errorString() << "]"; srvClientID += _hostname; } QString uniqueServerClientID = diff --git a/cockatrice/src/server/remote/remote_client.h b/cockatrice/src/server/remote/remote_client.h index 5d9bca63c..f34fdb71b 100644 --- a/cockatrice/src/server/remote/remote_client.h +++ b/cockatrice/src/server/remote/remote_client.h @@ -4,9 +4,12 @@ #include "../../client/game_logic/abstract_client.h" #include "pb/commands.pb.h" +#include #include #include +inline Q_LOGGING_CATEGORY(RemoteClientLog, "remote_client"); + class QTimer; class RemoteClient : public AbstractClient