feat(Core/Logging): rework logging (#4692)

* feat(Core/Logging): rework logging

* correct level for sql.sql

* del unused config options

* Correct build

* correct after merge

* whitespace

20:29:37 1. 'Player.cpp'. Replace (1)
20:29:37 2. 'ObjectMgr.cpp'. Replace (3)

* 1

* correct logging

* correct affter merge

* 1

* 2

* LOG_LEVEL_WARN

* #include "AppenderDB.h"

* 3

* 4

* 5

* 1. 'WorldSocket.cpp'. Replace (1)

* 6

* 1
This commit is contained in:
Kargatum
2021-04-17 16:20:07 +07:00
committed by GitHub
parent b2861be1cd
commit 4af4cbd3d9
246 changed files with 7413 additions and 6807 deletions

View File

@@ -211,7 +211,7 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result)
{
uint32 guidlow = (*result)[0].GetUInt32();
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDetail("Loading char guid %u from account %u.", guidlow, GetAccountId());
LOG_DEBUG("server", "Loading char guid %u from account %u.", guidlow, GetAccountId());
#endif
if (Player::BuildEnumData(result, &data))
{
@@ -282,7 +282,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
{
data << (uint8)CHAR_CREATE_FAILED;
SendPacket(&data);
sLog->outError("Class (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", class_, GetAccountId());
LOG_ERROR("server", "Class (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", class_, GetAccountId());
return;
}
@@ -291,7 +291,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
{
data << (uint8)CHAR_CREATE_FAILED;
SendPacket(&data);
sLog->outError("Race (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", race_, GetAccountId());
LOG_ERROR("server", "Race (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", race_, GetAccountId());
return;
}
@@ -299,7 +299,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
if (raceEntry->expansion > Expansion())
{
data << (uint8)CHAR_CREATE_EXPANSION;
sLog->outError("Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", Expansion(), GetAccountId(), raceEntry->expansion, race_);
LOG_ERROR("server", "Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", Expansion(), GetAccountId(), raceEntry->expansion, race_);
SendPacket(&data);
return;
}
@@ -308,7 +308,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
if (classEntry->expansion > Expansion())
{
data << (uint8)CHAR_CREATE_EXPANSION_CLASS;
sLog->outError("Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", Expansion(), GetAccountId(), classEntry->expansion, class_);
LOG_ERROR("server", "Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", Expansion(), GetAccountId(), classEntry->expansion, class_);
SendPacket(&data);
return;
}
@@ -337,7 +337,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
{
data << (uint8)CHAR_NAME_NO_NAME;
SendPacket(&data);
sLog->outError("Account:[%d] but tried to Create character with empty [name] ", GetAccountId());
LOG_ERROR("server", "Account:[%d] but tried to Create character with empty [name] ", GetAccountId());
return;
}
@@ -600,7 +600,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
uint8 unk;
createInfo->Data >> unk;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "Character creation %s (account %u) has unhandled tail data: [%u]", createInfo->Name.c_str(), GetAccountId(), unk);
LOG_DEBUG("network", "Character creation %s (account %u) has unhandled tail data: [%u]", createInfo->Name.c_str(), GetAccountId(), unk);
#endif
}
@@ -660,9 +660,9 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
std::string IP_str = GetRemoteAddress();
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDetail("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
LOG_DEBUG("server", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
#endif
sLog->outChar("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
LOG_INFO("entities.player", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
sScriptMgr->OnPlayerCreate(&newChar);
sWorld->AddGlobalPlayerData(newChar.GetGUIDLow(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel(), 0, 0);
@@ -729,19 +729,20 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
std::string IP_str = GetRemoteAddress();
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDetail("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));
LOG_DEBUG("server", "Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));
#endif
sLog->outChar("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));
LOG_INFO("entities.player", "Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));
// To prevent hook failure, place hook before removing reference from DB
sScriptMgr->OnPlayerDelete(guid, initAccountId); // To prevent race conditioning, but as it also makes sense, we hand the accountId over for successful delete.
// Shouldn't interfere with character deletion though
if (sLog->IsOutCharDump()) // optimize GetPlayerDump call
if (sLog->ShouldLog("entities.player.dump", LogLevel::LOG_LEVEL_INFO)) // optimize GetPlayerDump call
{
std::string dump;
if (PlayerDumpWriter().GetDump(GUID_LOPART(guid), dump))
sLog->outCharDump(dump.c_str(), GetAccountId(), GUID_LOPART(guid), name.c_str());
if (PlayerDumpWriter().GetDump(GUID_LOPART(guid), dump))\
LOG_CHAR_DUMP(dump.c_str(), GetAccountId(), GUID_LOPART(guid), name.c_str());
}
sCalendarMgr->RemoveAllPlayerEventsAndInvites(guid);
@@ -757,7 +758,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
{
if (PlayerLoading() || GetPlayer() != nullptr)
{
sLog->outError("Player tries to login again, AccountId = %d", GetAccountId());
LOG_ERROR("server", "Player tries to login again, AccountId = %d", GetAccountId());
KickPlayer("Player tries to login again");
return;
}
@@ -767,7 +768,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
if (!IsLegitCharacterForAccount(GUID_LOPART(playerGuid)))
{
sLog->outError("Account (%u) can't login with that character (%u).", GetAccountId(), GUID_LOPART(playerGuid));
LOG_ERROR("server", "Account (%u) can't login with that character (%u).", GetAccountId(), GUID_LOPART(playerGuid));
KickPlayer("Account can't login with this character");
return;
}
@@ -811,14 +812,14 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
{
if (limitA == 0 || --limitA == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode A");
LOG_INFO("misc", "HandlePlayerLoginOpcode A");
break;
}
while (sess->GetPlayer() && sess->GetPlayer()->IsBeingTeleportedFar())
{
if (limitB == 0 || --limitB == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode B");
LOG_INFO("misc", "HandlePlayerLoginOpcode B");
break;
}
sess->HandleMoveWorldportAckOpcode();
@@ -827,7 +828,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
{
if (limitC == 0 || --limitC == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode C");
LOG_INFO("misc", "HandlePlayerLoginOpcode C");
break;
}
Player* plMover = sess->GetPlayer()->m_mover->ToPlayer();
@@ -919,7 +920,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
chH.PSendSysMessage("%s", GitRevision::GetFullVersion());
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("WORLD: Sent server info");
LOG_DEBUG("server", "WORLD: Sent server info");
#endif
}
@@ -935,7 +936,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
}
else
{
sLog->outError("Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), guildId);
LOG_ERROR("server", "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), guildId);
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
@@ -983,8 +984,6 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation());
}
//sLog->outDebug("Player %s added to Map.", pCurrChar->GetName().c_str());
// pussywizard: optimization
std::string charName = pCurrChar->GetName();
std::transform(charName.begin(), charName.end(), charName.begin(), ::tolower);
@@ -1129,7 +1128,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
SendNotification(LANG_GM_ON);
std::string IP_str = GetRemoteAddress();
sLog->outChar("Account: %d (IP: %s) Login Character:[%s] (GUID: %u) Level: %d",
LOG_INFO("entities.player", "Account: %d (IP: %s) Login Character:[%s] (GUID: %u) Level: %d",
GetAccountId(), IP_str.c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), pCurrChar->getLevel());
if (!pCurrChar->IsStandState() && !pCurrChar->HasUnitState(UNIT_STATE_STUNNED))
@@ -1234,7 +1233,7 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar)
chH.PSendSysMessage("%s", GitRevision::GetFullVersion());
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("WORLD: Sent server info");
LOG_DEBUG("server", "WORLD: Sent server info");
#endif
}
@@ -1335,7 +1334,7 @@ void WorldSession::HandlePlayerLoginToCharOutOfWorld(Player* /*pCurrChar*/)
void WorldSession::HandleSetFactionAtWar(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("WORLD: Received CMSG_SET_FACTION_ATWAR");
LOG_DEBUG("server", "WORLD: Received CMSG_SET_FACTION_ATWAR");
#endif
uint32 repListID;
@@ -1350,7 +1349,7 @@ void WorldSession::HandleSetFactionAtWar(WorldPacket& recvData)
//I think this function is never used :/ I dunno, but i guess this opcode not exists
void WorldSession::HandleSetFactionCheat(WorldPacket& /*recvData*/)
{
sLog->outError("WORLD SESSION: HandleSetFactionCheat, not expected call, please report.");
LOG_ERROR("server", "WORLD SESSION: HandleSetFactionCheat, not expected call, please report.");
GetPlayer()->GetReputationMgr().SendStates();
}
@@ -1385,7 +1384,7 @@ void WorldSession::HandleTutorialReset(WorldPacket& /*recvData*/)
void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("WORLD: Received CMSG_SET_WATCHED_FACTION");
LOG_DEBUG("server", "WORLD: Received CMSG_SET_WATCHED_FACTION");
#endif
uint32 fact;
recvData >> fact;
@@ -1395,7 +1394,7 @@ void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket& recvData)
void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("WORLD: Received CMSG_SET_FACTION_INACTIVE");
LOG_DEBUG("server", "WORLD: Received CMSG_SET_FACTION_INACTIVE");
#endif
uint32 replistid;
uint8 inactive;
@@ -1407,7 +1406,7 @@ void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket& recvData)
void WorldSession::HandleShowingHelmOpcode(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("CMSG_SHOWING_HELM for %s", _player->GetName().c_str());
LOG_DEBUG("server", "CMSG_SHOWING_HELM for %s", _player->GetName().c_str());
#endif
recvData.read_skip<uint8>(); // unknown, bool?
_player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);
@@ -1416,7 +1415,7 @@ void WorldSession::HandleShowingHelmOpcode(WorldPacket& recvData)
void WorldSession::HandleShowingCloakOpcode(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outStaticDebug("CMSG_SHOWING_CLOAK for %s", _player->GetName().c_str());
LOG_DEBUG("server", "CMSG_SHOWING_CLOAK for %s", _player->GetName().c_str());
#endif
recvData.read_skip<uint8>(); // unknown, bool?
_player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK);
@@ -1519,7 +1518,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu
CharacterDatabase.Execute(stmt);
}
sLog->outChar("Account: %d (IP: %s), Character [%s] (guid: %u) Changed name to: %s", GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), guidLow, newName.c_str());
LOG_INFO("entities.player", "Account: %d (IP: %s), Character [%s] (guid: %u) Changed name to: %s", GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), guidLow, newName.c_str());
WorldPacket data(SMSG_CHAR_RENAME, 1 + 8 + (newName.size() + 1));
data << uint8(RESPONSE_SUCCESS);
@@ -1636,7 +1635,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)
void WorldSession::HandleAlterAppearance(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ALTER_APPEARANCE");
LOG_DEBUG("network", "CMSG_ALTER_APPEARANCE");
#endif
uint32 Hair, Color, FacialHair, SkinColor;
@@ -1715,7 +1714,7 @@ void WorldSession::HandleRemoveGlyph(WorldPacket& recvData)
if (slot >= MAX_GLYPH_SLOT_INDEX)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot);
LOG_DEBUG("network", "Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot);
#endif
return;
}
@@ -1739,7 +1738,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
recvData >> guid;
if (!IsLegitCharacterForAccount(GUID_LOPART(guid)))
{
sLog->outError("Account %u, IP: %s tried to customise character %u, but it does not belong to their account!",
LOG_ERROR("server", "Account %u, IP: %s tried to customise character %u, but it does not belong to their account!",
GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid));
recvData.rfinish();
KickPlayer("HandleCharCustomize");
@@ -1836,7 +1835,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
}
}
sLog->outChar("Account: %d (IP: %s), Character [%s] (guid: %u) Customized to: %s", GetAccountId(), GetRemoteAddress().c_str(), playerData->name.c_str(), GUID_LOPART(guid), newName.c_str());
LOG_INFO("entities.player", "Account: %d (IP: %s), Character [%s] (guid: %u) Customized to: %s", GetAccountId(), GetRemoteAddress().c_str(), playerData->name.c_str(), GUID_LOPART(guid), newName.c_str());
Player::Customize(guid, gender, skin, face, hairStyle, hairColor, facialHair);
@@ -1877,7 +1876,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
void WorldSession::HandleEquipmentSetSave(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_EQUIPMENT_SET_SAVE");
LOG_DEBUG("network", "CMSG_EQUIPMENT_SET_SAVE");
#endif
uint64 setGuid;
@@ -1938,7 +1937,7 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket& recvData)
void WorldSession::HandleEquipmentSetDelete(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_EQUIPMENT_SET_DELETE");
LOG_DEBUG("network", "CMSG_EQUIPMENT_SET_DELETE");
#endif
uint64 setGuid;
@@ -1950,7 +1949,7 @@ void WorldSession::HandleEquipmentSetDelete(WorldPacket& recvData)
void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_EQUIPMENT_SET_USE");
LOG_DEBUG("network", "CMSG_EQUIPMENT_SET_USE");
#endif
for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
@@ -1962,7 +1961,7 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData)
recvData >> srcbag >> srcslot;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Item " UI64FMTD ": srcbag %u, srcslot %u", itemGuid, srcbag, srcslot);
LOG_DEBUG("entities.player.items", "Item " UI64FMTD ": srcbag %u, srcslot %u", itemGuid, srcbag, srcslot);
#endif
// check if item slot is set to "ignored" (raw value == 1), must not be unequipped then
@@ -2044,7 +2043,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
if (!IsLegitCharacterForAccount(GUID_LOPART(guid)))
{
sLog->outError("Account %u, IP: %s tried to factionchange character %u, but it does not belong to their account!",
LOG_ERROR("server", "Account %u, IP: %s tried to factionchange character %u, but it does not belong to their account!",
GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid));
recvData.rfinish();
KickPlayer("HandleCharFactionOrRaceChange");
@@ -2266,7 +2265,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
stmt->setUInt32(0, lowGuid);
trans->Append(stmt);
sLog->outChar("Account: %d (IP: %s), Character [%s] (guid: %u) Changed Race/Faction to: %s", GetAccountId(), GetRemoteAddress().c_str(), playerData->name.c_str(), lowGuid, newname.c_str());
LOG_INFO("entities.player", "Account: %d (IP: %s), Character [%s] (guid: %u) Changed Race/Faction to: %s", GetAccountId(), GetRemoteAddress().c_str(), playerData->name.c_str(), lowGuid, newname.c_str());
// xinef: update global data
sWorld->UpdateGlobalNameData(GUID_LOPART(guid), playerData->name, newname);
@@ -2673,7 +2672,6 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
}
std::string IP_str = GetRemoteAddress();
//sLog->outDebug(LOG_FILTER_PLAYER, "%s (IP: %s) changed race from %u to %u", GetPlayerInfo().c_str(), IP_str.c_str(), oldRace, race);
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1 + 8 + (newname.size() + 1) + 1 + 1 + 1 + 1 + 1 + 1 + 1);
data << uint8(RESPONSE_SUCCESS);