implement custom protobuf debug string creation (#4532)

* implement custom protobuf debug log string creation

* add version guards

* add missing header

* debian10 repository misses headers

* clean up logging messages a bit

* fix some more formatting on debug messages
This commit is contained in:
ebbit1q 2022-02-23 23:46:23 +01:00 committed by GitHub
parent eb3ce1fd7e
commit 7108eb42c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 178 additions and 51 deletions

View file

@ -1,5 +1,6 @@
#include "isl_interface.h"
#include "debug_pb_message.h"
#include "get_pb_extension.h"
#include "main.h"
#include "pb/event_game_joined.pb.h"
@ -437,7 +438,7 @@ void IslInterface::processRoomCommand(const CommandContainer &cont, qint64 sessi
void IslInterface::processMessage(const IslMessage &item)
{
qDebug() << QString::fromStdString(item.DebugString());
qDebug() << getSafeDebugString(item);
switch (item.message_type()) {
case IslMessage::ROOM_COMMAND_CONTAINER: {

View file

@ -104,7 +104,7 @@ Servatrice_ConnectionPool *Servatrice_GameServer::findLeastUsedConnectionPool()
}
debugStr.append(QString::number(clientCount));
}
qDebug() << "Pool utilisation:" << debugStr;
qDebug().noquote() << "Pool utilisation:" << debugStr.join(", ");
return connectionPools[poolIndex];
}
@ -176,7 +176,7 @@ Servatrice_ConnectionPool *Servatrice_WebsocketGameServer::findLeastUsedConnecti
}
debugStr.append(QString::number(clientCount));
}
qDebug() << "Pool utilisation:" << debugStr;
qDebug().noquote() << "Pool utilisation:" << debugStr.join(", ");
return connectionPools[poolIndex];
}
@ -241,18 +241,18 @@ bool Servatrice::initServer()
authenticationMethod = AuthenticationNone;
}
qDebug() << "Store Replays: " << getStoreReplaysEnabled();
qDebug() << "Client ID Required: " << getClientIDRequiredEnabled();
qDebug() << "Maximum user limit enabled: " << getMaxUserLimitEnabled();
qDebug() << "Store Replays:" << getStoreReplaysEnabled();
qDebug() << "Client ID Required:" << getClientIDRequiredEnabled();
qDebug() << "Maximum user limit enabled:" << getMaxUserLimitEnabled();
if (getMaxUserLimitEnabled()) {
qDebug() << "Maximum total user limit: " << getMaxUserTotal();
qDebug() << "Maximum tcp user limit: " << getMaxTcpUserLimit();
qDebug() << "Maximum websocket user limit: " << getMaxWebSocketUserLimit();
qDebug() << "Maximum total user limit:" << getMaxUserTotal();
qDebug() << "Maximum tcp user limit:" << getMaxTcpUserLimit();
qDebug() << "Maximum websocket user limit:" << getMaxWebSocketUserLimit();
}
qDebug() << "Accept registered users only: " << getRegOnlyServerEnabled();
qDebug() << "Registration enabled: " << getRegistrationEnabled();
qDebug() << "Accept registered users only:" << getRegOnlyServerEnabled();
qDebug() << "Registration enabled:" << getRegistrationEnabled();
if (getRegistrationEnabled()) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList emailBlackListFilters = getEmailBlackList().split(",", Qt::SkipEmptyParts);
@ -261,32 +261,32 @@ bool Servatrice::initServer()
QStringList emailBlackListFilters = getEmailBlackList().split(",", QString::SkipEmptyParts);
QStringList emailWhiteListFilters = getEmailWhiteList().split(",", QString::SkipEmptyParts);
#endif
qDebug() << "Email blacklist: " << emailBlackListFilters;
qDebug() << "Email whitelist: " << emailWhiteListFilters;
qDebug() << "Require email address to register: " << getRequireEmailForRegistrationEnabled();
qDebug() << "Require email activation via token: " << getRequireEmailActivationEnabled();
qDebug() << "Email blacklist:" << emailBlackListFilters;
qDebug() << "Email whitelist:" << emailWhiteListFilters;
qDebug() << "Require email address to register:" << getRequireEmailForRegistrationEnabled();
qDebug() << "Require email activation via token:" << getRequireEmailActivationEnabled();
if (getMaxAccountsPerEmail()) {
qDebug() << "Maximum number of accounts per email: " << getMaxAccountsPerEmail();
qDebug() << "Maximum number of accounts per email:" << getMaxAccountsPerEmail();
} else {
qDebug() << "Maximum number of accounts per email: unlimited";
}
qDebug() << "Enable Internal SMTP Client: " << getEnableInternalSMTPClient();
qDebug() << "Enable Internal SMTP Client:" << getEnableInternalSMTPClient();
if (!getEnableInternalSMTPClient()) {
qDebug() << "WARNING: Registrations are enabled but internal SMTP client is disabled. Users activation "
"emails will not be automatically mailed to users!";
}
}
qDebug() << "Reset password enabled: " << getEnableForgotPassword();
qDebug() << "Reset password enabled:" << getEnableForgotPassword();
if (getEnableForgotPassword()) {
qDebug() << "Reset password token life (in minutes): " << getForgotPasswordTokenLife();
qDebug() << "Reset password challenge on: " << getEnableForgotPasswordChallenge();
qDebug() << "Reset password token life (in minutes):" << getForgotPasswordTokenLife();
qDebug() << "Reset password challenge on:" << getEnableForgotPasswordChallenge();
}
qDebug() << "Auditing enabled: " << getEnableAudit();
qDebug() << "Auditing enabled:" << getEnableAudit();
if (getEnableAudit()) {
qDebug() << "Audit registration attempts enabled: " << getEnableRegistrationAudit();
qDebug() << "Audit reset password attepts enabled: " << getEnableForgotPasswordAudit();
qDebug() << "Audit registration attempts enabled:" << getEnableRegistrationAudit();
qDebug() << "Audit reset password attepts enabled:" << getEnableForgotPasswordAudit();
}
if (getDBTypeString() == "mysql") {
@ -423,7 +423,7 @@ bool Servatrice::initServer()
statusUpdateClock = new QTimer(this);
connect(statusUpdateClock, SIGNAL(timeout()), this, SLOT(statusUpdate()));
if (getServerStatusUpdateTime() != 0) {
qDebug() << "Starting status update clock, interval " << getServerStatusUpdateTime() << " ms";
qDebug() << "Starting status update clock, interval" << getServerStatusUpdateTime() << "ms";
statusUpdateClock->start(getServerStatusUpdateTime());
}
@ -459,7 +459,7 @@ bool Servatrice::initServer()
}
if (getIdleClientTimeout() > 0) {
qDebug() << "Idle client timeout value: " << getIdleClientTimeout();
qDebug() << "Idle client timeout value:" << getIdleClientTimeout();
if (getIdleClientTimeout() < 300)
qDebug() << "WARNING: It is not recommended to set the IdleClientTimeout value very low. Doing so will "
"cause clients to very quickly be disconnected. Many players when connected may be searching "
@ -573,7 +573,7 @@ void Servatrice::setRequiredFeatures(const QString featureList)
foreach (QString reqFeature, listReqFeatures)
features.enableRequiredFeature(serverRequiredFeatureList, reqFeature);
qDebug() << "Set required client features to: " << serverRequiredFeatureList;
qDebug() << "Set required client features to:" << serverRequiredFeatureList;
}
void Servatrice::statusUpdate()

View file

@ -56,7 +56,7 @@ bool Servatrice_DatabaseInterface::openDatabase()
sqlDatabase.close();
const QString poolStr = instanceId == -1 ? QString("main") : QString("pool %1").arg(instanceId);
qDebug() << QString("[%1] Opening database...").arg(poolStr);
qDebug().noquote() << QString("[%1] Opening database...").arg(poolStr);
if (!sqlDatabase.open()) {
qCritical() << QString("[%1] Error opening database: %2").arg(poolStr).arg(sqlDatabase.lastError().text());
return false;

View file

@ -1047,7 +1047,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
{
QString userName = nameFromStdString(cmd.user_name());
QString clientId = nameFromStdString(cmd.clientid());
qDebug() << "Got register command: " << userName;
qDebug() << "Got register command for user:" << userName;
bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool();
if (!registrationEnabled) {
@ -1189,7 +1189,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdRegisterAccount(const C
country, !requireEmailActivation);
if (regSucceeded) {
qDebug() << "Accepted register command for user: " << userName;
qDebug() << "Accepted register command for user:" << userName;
if (requireEmailActivation) {
QSqlQuery *query =
sqlInterface->prepareQuery("insert into {prefix}_activation_emails (name) values(:name)");
@ -1393,7 +1393,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordRequest(c
const QString userName = nameFromStdString(cmd.user_name());
const QString clientId = nameFromStdString(cmd.clientid());
qDebug() << "Received reset password request from user: " << userName;
qDebug() << "Received reset password request from user:" << userName;
if (!servatrice->getEnableForgotPassword()) {
if (servatrice->getEnableForgotPasswordAudit())
@ -1475,7 +1475,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdForgotPasswordReset(con
Q_UNUSED(rc);
QString userName = nameFromStdString(cmd.user_name());
QString clientId = nameFromStdString(cmd.clientid());
qDebug() << "Received reset password reset from user: " << userName;
qDebug() << "Received reset password reset from user:" << userName;
if (!sqlInterface->doesForgotPasswordExist(userName)) {
if (servatrice->getEnableForgotPasswordAudit())
@ -1526,7 +1526,7 @@ AbstractServerSocketInterface::cmdForgotPasswordChallenge(const Command_ForgotPa
const QString userName = nameFromStdString(cmd.user_name());
const QString clientId = nameFromStdString(cmd.clientid());
qDebug() << "Received reset password challenge from user: " << userName;
qDebug() << "Received reset password challenge from user:" << userName;
if (!servatrice->getEnableForgotPasswordChallenge()) {
if (servatrice->getEnableForgotPasswordAudit()) {