Convert 'UCS' debugging _log to logger.LogDebugType

This commit is contained in:
Akkadius
2015-01-12 22:44:47 -06:00
parent f26f49c2a1
commit 40d32fc1e5
8 changed files with 126 additions and 120 deletions
+40 -39
View File
@@ -19,6 +19,7 @@
#include "../common/debug.h"
#include "../common/string_util.h"
#include "../common/eqemu_logsys.h"
#include "clientlist.h"
#include "database.h"
@@ -235,7 +236,7 @@ std::vector<std::string> ParseRecipients(std::string RecipientString) {
static void ProcessMailTo(Client *c, std::string MailMessage) {
_log(UCS__TRACE, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
std::vector<std::string> Recipients;
@@ -304,7 +305,7 @@ static void ProcessMailTo(Client *c, std::string MailMessage) {
if (!database.SendMail(Recipient, c->MailBoxName(), Subject, Body, RecipientsString)) {
_log(UCS__ERROR, "Failed in SendMail(%s, %s, %s, %s)", Recipient.c_str(),
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Failed in SendMail(%s, %s, %s, %s)", Recipient.c_str(),
c->MailBoxName().c_str(), Subject.c_str(), RecipientsString.c_str());
int PacketLength = 10 + Recipient.length() + Subject.length();
@@ -399,7 +400,7 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) {
static void ProcessCommandBuddy(Client *c, std::string Buddy) {
_log(UCS__TRACE, "Received buddy command with parameters %s", Buddy.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Received buddy command with parameters %s", Buddy.c_str());
c->GeneralChannelMessage("Buddy list modified");
uint8 SubAction = 1;
@@ -429,7 +430,7 @@ static void ProcessCommandBuddy(Client *c, std::string Buddy) {
static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
_log(UCS__TRACE, "Received ignore command with parameters %s", Ignoree.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Received ignore command with parameters %s", Ignoree.c_str());
c->GeneralChannelMessage("Ignore list modified");
uint8 SubAction = 0;
@@ -480,9 +481,9 @@ Clientlist::Clientlist(int ChatPort) {
exit(1);
if (chatsf->Open())
_log(UCS__INIT,"Client (UDP) Chat listener started on port %i.", ChatPort);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server,"Client (UDP) Chat listener started on port %i.", ChatPort);
else {
_log(UCS__ERROR,"Failed to start client (UDP) listener (port %-4i)", ChatPort);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server,"Failed to start client (UDP) listener (port %-4i)", ChatPort);
exit(1);
}
@@ -559,13 +560,13 @@ void Clientlist::CheckForStaleConnections(Client *c) {
if(((*Iterator) != c) && ((c->GetName() == (*Iterator)->GetName())
&& (c->GetConnectionType() == (*Iterator)->GetConnectionType()))) {
_log(UCS__CLIENT, "Removing old connection for %s", c->GetName().c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Removing old connection for %s", c->GetName().c_str());
struct in_addr in;
in.s_addr = (*Iterator)->ClientStream->GetRemoteIP();
_log(UCS__CLIENT, "Client connection from %s:%d closed.", inet_ntoa(in),
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in),
ntohs((*Iterator)->ClientStream->GetRemotePort()));
safe_delete((*Iterator));
@@ -585,7 +586,7 @@ void Clientlist::Process() {
in.s_addr = eqs->GetRemoteIP();
_log(UCS__CLIENT, "New Client UDP connection from %s:%d", inet_ntoa(in), ntohs(eqs->GetRemotePort()));
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "New Client UDP connection from %s:%d", inet_ntoa(in), ntohs(eqs->GetRemotePort()));
eqs->SetOpcodeManager(&ChatOpMgr);
@@ -605,7 +606,7 @@ void Clientlist::Process() {
in.s_addr = (*Iterator)->ClientStream->GetRemoteIP();
_log(UCS__CLIENT, "Client connection from %s:%d closed.", inet_ntoa(in),
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in),
ntohs((*Iterator)->ClientStream->GetRemotePort()));
safe_delete((*Iterator));
@@ -645,7 +646,7 @@ void Clientlist::Process() {
if(strlen(PacketBuffer) != 9)
{
_log(UCS__ERROR, "Mail key is the wrong size. Version of world incompatible with UCS.");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Mail key is the wrong size. Version of world incompatible with UCS.");
KeyValid = false;
break;
}
@@ -666,11 +667,11 @@ void Clientlist::Process() {
else
CharacterName = MailBoxString.substr(LastPeriod + 1);
_log(UCS__TRACE, "Received login for user %s with key %s", MailBox, Key);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Received login for user %s with key %s", MailBox, Key);
if(!database.VerifyMailKey(CharacterName, (*Iterator)->ClientStream->GetRemoteIP(), Key)) {
_log(UCS__ERROR, "Chat Key for %s does not match, closing connection.", MailBox);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Chat Key for %s does not match, closing connection.", MailBox);
KeyValid = false;
@@ -702,7 +703,7 @@ void Clientlist::Process() {
default: {
_log(UCS__ERROR, "Unhandled chat opcode %8X", opcode);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Unhandled chat opcode %8X", opcode);
break;
}
}
@@ -715,7 +716,7 @@ void Clientlist::Process() {
in.s_addr = (*Iterator)->ClientStream->GetRemoteIP();
_log(UCS__TRACE, "Force disconnecting client: %s:%d, KeyValid=%i, GetForceDisconnect()=%i",
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Force disconnecting client: %s:%d, KeyValid=%i, GetForceDisconnect()=%i",
inet_ntoa(in), ntohs((*Iterator)->ClientStream->GetRemotePort()),
KeyValid, (*Iterator)->GetForceDisconnect());
@@ -859,7 +860,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
break;
case CommandSetMessageStatus:
_log(UCS__TRACE, "Set Message Status, Params: %s", Parameters.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Set Message Status, Params: %s", Parameters.c_str());
ProcessSetMessageStatus(Parameters);
break;
@@ -884,7 +885,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
default:
c->SendHelp();
_log(UCS__ERROR, "Unhandled OP_Mail command: %s", CommandString.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Unhandled OP_Mail command: %s", CommandString.c_str());
}
}
@@ -895,7 +896,7 @@ void Clientlist::CloseAllConnections() {
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) {
_log(UCS__TRACE, "Removing client %s", (*Iterator)->GetName().c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Removing client %s", (*Iterator)->GetName().c_str());
(*Iterator)->CloseConnection();
}
@@ -904,7 +905,7 @@ void Clientlist::CloseAllConnections() {
void Client::AddCharacter(int CharID, const char *CharacterName, int Level) {
if(!CharacterName) return;
_log(UCS__TRACE, "Adding character %s with ID %i for %s", CharacterName, CharID, GetName().c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Adding character %s with ID %i for %s", CharacterName, CharID, GetName().c_str());
CharacterEntry NewCharacter;
NewCharacter.CharID = CharID;
NewCharacter.Name = CharacterName;
@@ -970,7 +971,7 @@ void Client::AddToChannelList(ChatChannel *JoinedChannel) {
for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
if(JoinedChannels[i] == nullptr) {
JoinedChannels[i] = JoinedChannel;
_log(UCS__TRACE, "Added Channel %s to slot %i for %s", JoinedChannel->GetName().c_str(), i + 1, GetName().c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Added Channel %s to slot %i for %s", JoinedChannel->GetName().c_str(), i + 1, GetName().c_str());
return;
}
}
@@ -1011,7 +1012,7 @@ void Client::JoinChannels(std::string ChannelNameList) {
}
}
_log(UCS__TRACE, "Client: %s joining channels %s", GetName().c_str(), ChannelNameList.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Client: %s joining channels %s", GetName().c_str(), ChannelNameList.c_str());
int NumberOfChannels = ChannelCount();
@@ -1112,7 +1113,7 @@ void Client::JoinChannels(std::string ChannelNameList) {
void Client::LeaveChannels(std::string ChannelNameList) {
_log(UCS__TRACE, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
std::string::size_type CurrentPos = 0;
@@ -1291,7 +1292,7 @@ void Client::SendChannelMessage(std::string Message)
std::string ChannelName = Message.substr(1, MessageStart-1);
_log(UCS__TRACE, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str());
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
@@ -1434,7 +1435,7 @@ void Client::SendChannelMessageByNumber(std::string Message) {
}
}
_log(UCS__TRACE, "%s tells %s, [%s]", GetName().c_str(), RequiredChannel->GetName().c_str(),
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), RequiredChannel->GetName().c_str(),
Message.substr(MessageStart + 1).c_str());
if(RuleB(Chat, EnableAntiSpam))
@@ -1646,7 +1647,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) {
else
Message = "Password change on channel " + ChannelName;
_log(UCS__TRACE, "Set password of channel [%s] to [%s] by %s", ChannelName.c_str(), Password.c_str(), GetName().c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Set password of channel [%s] to [%s] by %s", ChannelName.c_str(), Password.c_str(), GetName().c_str());
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
@@ -1701,7 +1702,7 @@ void Client::SetChannelOwner(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
_log(UCS__TRACE, "Set owner of channel [%s] to [%s]", ChannelName.c_str(), NewOwner.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Set owner of channel [%s] to [%s]", ChannelName.c_str(), NewOwner.c_str());
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
@@ -1789,7 +1790,7 @@ void Client::ChannelInvite(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
_log(UCS__TRACE, "[%s] invites [%s] to channel [%s]", GetName().c_str(), Invitee.c_str(), ChannelName.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "[%s] invites [%s] to channel [%s]", GetName().c_str(), Invitee.c_str(), ChannelName.c_str());
Client *RequiredClient = CL->FindCharacter(Invitee);
@@ -1917,7 +1918,7 @@ void Client::ChannelGrantModerator(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
_log(UCS__TRACE, "[%s] gives [%s] moderator rights to channel [%s]", GetName().c_str(), Moderator.c_str(), ChannelName.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "[%s] gives [%s] moderator rights to channel [%s]", GetName().c_str(), Moderator.c_str(), ChannelName.c_str());
Client *RequiredClient = CL->FindCharacter(Moderator);
@@ -1998,7 +1999,7 @@ void Client::ChannelGrantVoice(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
_log(UCS__TRACE, "[%s] gives [%s] voice to channel [%s]", GetName().c_str(), Voicee.c_str(), ChannelName.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "[%s] gives [%s] voice to channel [%s]", GetName().c_str(), Voicee.c_str(), ChannelName.c_str());
Client *RequiredClient = CL->FindCharacter(Voicee);
@@ -2086,7 +2087,7 @@ void Client::ChannelKick(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
_log(UCS__TRACE, "[%s] kicks [%s] from channel [%s]", GetName().c_str(), Kickee.c_str(), ChannelName.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "[%s] kicks [%s] from channel [%s]", GetName().c_str(), Kickee.c_str(), ChannelName.c_str());
Client *RequiredClient = CL->FindCharacter(Kickee);
@@ -2195,32 +2196,32 @@ void Client::SetConnectionType(char c) {
case 'S':
{
TypeOfConnection = ConnectionTypeCombined;
_log(UCS__TRACE, "Connection type is Combined (SoF/SoD)");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Connection type is Combined (SoF/SoD)");
break;
}
case 'U':
{
TypeOfConnection = ConnectionTypeCombined;
UnderfootOrLater = true;
_log(UCS__TRACE, "Connection type is Combined (Underfoot+)");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Connection type is Combined (Underfoot+)");
break;
}
case 'M':
{
TypeOfConnection = ConnectionTypeMail;
_log(UCS__TRACE, "Connection type is Mail (6.2 or Titanium client)");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Connection type is Mail (6.2 or Titanium client)");
break;
}
case 'C':
{
TypeOfConnection = ConnectionTypeChat;
_log(UCS__TRACE, "Connection type is Chat (6.2 or Titanium client)");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Connection type is Chat (6.2 or Titanium client)");
break;
}
default:
{
TypeOfConnection = ConnectionTypeUnknown;
_log(UCS__TRACE, "Connection type is unknown.");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "Connection type is unknown.");
}
}
}
@@ -2298,11 +2299,11 @@ void Client::SendNotification(int MailBoxNumber, std::string Subject, std::strin
void Client::ChangeMailBox(int NewMailBox) {
_log(UCS__TRACE, "%s Change to mailbox %i", MailBoxName().c_str(), NewMailBox);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "%s Change to mailbox %i", MailBoxName().c_str(), NewMailBox);
SetMailBox(NewMailBox);
_log(UCS__TRACE, "New mailbox is %s", MailBoxName().c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "New mailbox is %s", MailBoxName().c_str());
auto outapp = new EQApplicationPacket(OP_MailboxChange, 2);
@@ -2376,13 +2377,13 @@ std::string Client::MailBoxName() {
if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1)))
{
_log(UCS__ERROR, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i",
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i",
CurrentMailBox, Characters.size());
return "";
}
_log(UCS__TRACE, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i",
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i",
CurrentMailBox, Characters.size());
return Characters[CurrentMailBox].Name;