mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-25 04:14:34 -08:00
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:
@@ -1,5 +1,6 @@
|
||||
#include "server_protocolhandler.h"
|
||||
|
||||
#include "debug_pb_message.h"
|
||||
#include "featureset.h"
|
||||
#include "get_pb_extension.h"
|
||||
#include "pb/commands.pb.h"
|
||||
@@ -134,17 +135,8 @@ Response::ResponseCode Server_ProtocolHandler::processSessionCommandContainer(co
|
||||
Response::ResponseCode resp = Response::RespInvalidCommand;
|
||||
const SessionCommand &sc = cont.session_command(i);
|
||||
const int num = getPbExtension(sc);
|
||||
if (num != SessionCommand::PING) { // don't log ping commands
|
||||
if (num == SessionCommand::LOGIN) { // log login commands, but hide passwords
|
||||
SessionCommand debugSc(sc);
|
||||
debugSc.MutableExtension(Command_Login::ext)->clear_password();
|
||||
logDebugMessage(QString::fromStdString(debugSc.ShortDebugString()));
|
||||
} else if (num == SessionCommand::REGISTER) {
|
||||
SessionCommand logSc(sc);
|
||||
logSc.MutableExtension(Command_Register::ext)->clear_password();
|
||||
logDebugMessage(QString::fromStdString(logSc.ShortDebugString()));
|
||||
} else
|
||||
logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
|
||||
if (num != SessionCommand::PING) { // don't log ping commands
|
||||
logDebugMessage(getSafeDebugString(sc));
|
||||
}
|
||||
switch ((SessionCommand::SessionCommandType)num) {
|
||||
case SessionCommand::PING:
|
||||
@@ -198,7 +190,7 @@ Response::ResponseCode Server_ProtocolHandler::processRoomCommandContainer(const
|
||||
Response::ResponseCode resp = Response::RespInvalidCommand;
|
||||
const RoomCommand &sc = cont.room_command(i);
|
||||
const int num = getPbExtension(sc);
|
||||
logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
|
||||
logDebugMessage(getSafeDebugString(sc));
|
||||
switch ((RoomCommand::RoomCommandType)num) {
|
||||
case RoomCommand::LEAVE_ROOM:
|
||||
resp = cmdLeaveRoom(sc.GetExtension(Command_LeaveRoom::ext), room, rc);
|
||||
@@ -277,7 +269,7 @@ Response::ResponseCode Server_ProtocolHandler::processGameCommandContainer(const
|
||||
for (int i = cont.game_command_size() - 1; i >= 0; --i) {
|
||||
const GameCommand &sc = cont.game_command(i);
|
||||
logDebugMessage(QString("game %1 player %2: ").arg(cont.game_id()).arg(roomIdAndPlayerId.second) +
|
||||
QString::fromStdString(sc.ShortDebugString()));
|
||||
getSafeDebugString(sc));
|
||||
|
||||
if (commandCountingInterval > 0) {
|
||||
int totalCount = 0;
|
||||
@@ -321,7 +313,7 @@ Response::ResponseCode Server_ProtocolHandler::processModeratorCommandContainer(
|
||||
Response::ResponseCode resp = Response::RespInvalidCommand;
|
||||
const ModeratorCommand &sc = cont.moderator_command(i);
|
||||
const int num = getPbExtension(sc);
|
||||
logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
|
||||
logDebugMessage(getSafeDebugString(sc));
|
||||
|
||||
resp = processExtendedModeratorCommand(num, sc, rc);
|
||||
if (resp != Response::RespOk)
|
||||
@@ -345,7 +337,7 @@ Response::ResponseCode Server_ProtocolHandler::processAdminCommandContainer(cons
|
||||
Response::ResponseCode resp = Response::RespInvalidCommand;
|
||||
const AdminCommand &sc = cont.admin_command(i);
|
||||
const int num = getPbExtension(sc);
|
||||
logDebugMessage(QString::fromStdString(sc.ShortDebugString()));
|
||||
logDebugMessage(getSafeDebugString(sc));
|
||||
|
||||
resp = processExtendedAdminCommand(num, sc, rc);
|
||||
if (resp != Response::RespOk)
|
||||
|
||||
Reference in New Issue
Block a user