refactor(Core/Logging): switch to fmt style for LOG_ (#10366)

* feat(Core/Common): add support fmt style for ASSERT and ABORT

* correct CheckCompactArrayMaskOverflow

* 1

* Update src/server/game/Spells/Spell.cpp

* rework logging

* add fmt replace logs

* logging

* FMT_LOG_

* settings

* fix startup

* 1

* 2

* 3

* 4

* 5

* fmt::print

* to fmt
This commit is contained in:
Kargatum
2022-01-27 22:44:41 +07:00
committed by GitHub
parent 5228d29379
commit 5969df4e30
211 changed files with 3689 additions and 3842 deletions

View File

@@ -36,26 +36,26 @@ public:
switch (type)
{
case CHAT_MSG_SAY:
LOG_CHAT("say", "Player %s says (language %u): %s",
player->GetName().c_str(), lang, msg.c_str());
LOG_CHAT("say", "Player {} says (language {}): {}",
player->GetName(), lang, msg);
break;
case CHAT_MSG_EMOTE:
LOG_CHAT("emote", "Player %s emotes: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("emote", "Player {} emotes: {}",
player->GetName(), msg);
break;
case CHAT_MSG_YELL:
LOG_CHAT("yell", "Player %s yells (language %u): %s",
player->GetName().c_str(), lang, msg.c_str());
LOG_CHAT("yell", "Player {} yells (language {}): {}",
player->GetName(), lang, msg);
break;
}
}
void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver) override
{
LOG_CHAT("whisper", "Player %s tells %s: %s",
player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str());
LOG_CHAT("whisper", "Player {} tells {}: {}",
player->GetName(), receiver ? receiver->GetName() : "<unknown>", msg);
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) override
@@ -65,38 +65,38 @@ public:
switch (type)
{
case CHAT_MSG_PARTY:
LOG_CHAT("party", "Player %s tells group with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
LOG_CHAT("party", "Player {} tells group with leader {}: {}",
player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg);
break;
case CHAT_MSG_PARTY_LEADER:
LOG_CHAT("party", "Leader %s tells group: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("party", "Leader {} tells group: {}",
player->GetName(), msg);
break;
case CHAT_MSG_RAID:
LOG_CHAT("raid", "Player %s tells raid with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
LOG_CHAT("raid", "Player {} tells raid with leader {}: {}",
player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg);
break;
case CHAT_MSG_RAID_LEADER:
LOG_CHAT("raid", "Leader player %s tells raid: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("raid", "Leader player {} tells raid: {}",
player->GetName(), msg);
break;
case CHAT_MSG_RAID_WARNING:
LOG_CHAT("raid", "Leader player %s warns raid with: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("raid", "Leader player {} warns raid with: {}",
player->GetName(), msg);
break;
case CHAT_MSG_BATTLEGROUND:
LOG_CHAT("bg", "Player %s tells battleground with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
LOG_CHAT("bg", "Player {} tells battleground with leader {}: {}",
player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg);
break;
case CHAT_MSG_BATTLEGROUND_LEADER:
LOG_CHAT("bg", "Leader player %s tells battleground: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("bg", "Leader player {} tells battleground: {}",
player->GetName(), msg);
break;
}
}
@@ -106,13 +106,13 @@ public:
switch (type)
{
case CHAT_MSG_GUILD:
LOG_CHAT("guild", "Player %s tells guild %s: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
LOG_CHAT("guild", "Player {} tells guild {}: {}",
player->GetName(), guild ? guild->GetName() : "<unknown>", msg);
break;
case CHAT_MSG_OFFICER:
LOG_CHAT("guild.officer", "Player %s tells guild %s officers: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
LOG_CHAT("guild.officer", "Player {} tells guild {} officers: {}",
player->GetName(), guild ? guild->GetName() : "<unknown>", msg);
break;
}
}
@@ -127,14 +127,14 @@ public:
if (isSystem)
{
LOG_CHAT("system", "Player %s tells channel %s: %s",
player->GetName().c_str(), channel->GetName().c_str(), msg.c_str());
LOG_CHAT("system", "Player {} tells channel {}: {}",
player->GetName(), channel->GetName(), msg);
}
else
{
std::string channelName = channel ? channel->GetName() : "<unknown>";
LOG_CHAT("channel." + channelName, "Player %s tells channel %s: %s",
player->GetName().c_str(), channelName.c_str(), msg.c_str());
LOG_CHAT("channel." + channelName, "Player {} tells channel {}: {}",
player->GetName(), channelName, msg);
}
}
};

View File

@@ -283,7 +283,7 @@ bool EquippedOk(Player* player, uint32 spellId)
if (item && item->GetTemplate()->RequiredSpell == reqSpell)
{
//player has item equipped that require specialty. Not allow to unlearn, player has to unequip first
LOG_DEBUG("scripts.ai", "Player attempt to unlearn spell %u, but item %u is equipped.", reqSpell, item->GetEntry());
LOG_DEBUG("scripts.ai", "Player attempt to unlearn spell {}, but item {} is equipped.", reqSpell, item->GetEntry());
return false;
}
}

View File

@@ -521,14 +521,14 @@ public:
}
if (!SpawnAssoc)
LOG_ERROR("sql.sql", "TCSR: Creature template entry %u has ScriptName npc_air_force_bots, but it's not handled by that script", creature->GetEntry());
LOG_ERROR("sql.sql", "TCSR: Creature template entry {} has ScriptName npc_air_force_bots, but it's not handled by that script", creature->GetEntry());
else
{
CreatureTemplate const* spawnedTemplate = sObjectMgr->GetCreatureTemplate(SpawnAssoc->spawnedCreatureEntry);
if (!spawnedTemplate)
{
LOG_ERROR("sql.sql", "TCSR: Creature template entry %u does not exist in DB, which is required by npc_air_force_bots", SpawnAssoc->spawnedCreatureEntry);
LOG_ERROR("sql.sql", "TCSR: Creature template entry {} does not exist in DB, which is required by npc_air_force_bots", SpawnAssoc->spawnedCreatureEntry);
SpawnAssoc = nullptr;
return;
}
@@ -548,7 +548,7 @@ public:
SpawnedGUID = summoned->GetGUID();
else
{
LOG_ERROR("sql.sql", "TCSR: npc_air_force_bots: wasn't able to spawn Creature %u", SpawnAssoc->spawnedCreatureEntry);
LOG_ERROR("sql.sql", "TCSR: npc_air_force_bots: wasn't able to spawn Creature {}", SpawnAssoc->spawnedCreatureEntry);
SpawnAssoc = nullptr;
}