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

@@ -9,6 +9,12 @@
#include "Guild.h"
#include "ScriptMgr.h"
#define LOG_CHAT(TYPE, ...) \
if (lang != LANG_ADDON) \
LOG_DEBUG("chat.log." TYPE, __VA_ARGS__); \
else \
LOG_DEBUG("chat.log.addon." TYPE, __VA_ARGS__);
class ChatLogScript : public PlayerScript
{
public:
@@ -18,40 +24,27 @@ public:
{
switch (type)
{
case CHAT_MSG_ADDON:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s sends: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_SAY:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC))
sLog->outChat("[SAY] Player %s says (language %u): %s",
player->GetName().c_str(), lang, msg.c_str());
LOG_CHAT("say", "Player %s says (language %u): %s",
player->GetName().c_str(), lang, msg.c_str());
break;
case CHAT_MSG_EMOTE:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC))
sLog->outChat("[TEXTEMOTE] Player %s emotes: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("emote", "Player %s emotes: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_YELL:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC))
sLog->outChat("[YELL] Player %s yells (language %u): %s",
player->GetName().c_str(), lang, msg.c_str());
LOG_CHAT("yell", "Player %s yells (language %u): %s",
player->GetName().c_str(), lang, msg.c_str());
break;
}
}
void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver) override
{
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_WHISPER))
sLog->outChat("[WHISPER] Player %s tells %s: %s",
player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s tells %s: %s",
player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str());
LOG_CHAT("whisper", "Player %s tells %s: %s",
player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str());
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) override
@@ -61,54 +54,38 @@ public:
switch (type)
{
case CHAT_MSG_PARTY:
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_PARTY))
sLog->outChat("[PARTY] Player %s tells group with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s tells group with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
LOG_CHAT("party", "Player %s tells group with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
break;
case CHAT_MSG_PARTY_LEADER:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_PARTY))
sLog->outChat("[PARTY] Leader %s tells group: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("party", "Leader %s tells group: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_RAID:
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_RAID))
sLog->outChat("[RAID] Player %s tells raid with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s tells raid with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
LOG_CHAT("raid", "Player %s tells raid with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
break;
case CHAT_MSG_RAID_LEADER:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_RAID))
sLog->outChat("[RAID] Leader player %s tells raid: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("raid", "Leader player %s tells raid: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_RAID_WARNING:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_RAID))
sLog->outChat("[RAID] Leader player %s warns raid with: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("raid", "Leader player %s warns raid with: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_BATTLEGROUND:
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_BGROUND))
sLog->outChat("[BATTLEGROUND] Player %s tells battleground with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s tells battleground with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
LOG_CHAT("bg", "Player %s tells battleground with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
break;
case CHAT_MSG_BATTLEGROUND_LEADER:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_BGROUND))
sLog->outChat("[BATTLEGROUND] Leader player %s tells battleground: %s",
player->GetName().c_str(), msg.c_str());
LOG_CHAT("bg", "Leader player %s tells battleground: %s",
player->GetName().c_str(), msg.c_str());
break;
}
}
@@ -118,23 +95,18 @@ public:
switch (type)
{
case CHAT_MSG_GUILD:
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_GUILD))
sLog->outChat("[GUILD] Player %s tells guild %s: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s sends to guild %s: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
LOG_CHAT("guild", "Player %s tells guild %s: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
break;
case CHAT_MSG_OFFICER:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_GUILD))
sLog->outChat("[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 %s tells guild %s officers: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
break;
}
}
void OnChat(Player* player, uint32 /*type*/, uint32 /*lang*/, std::string& msg, Channel* channel) override
void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Channel* channel) override
{
bool isSystem = channel &&
(channel->HasFlag(CHANNEL_FLAG_TRADE) ||
@@ -142,12 +114,17 @@ public:
channel->HasFlag(CHANNEL_FLAG_CITY) ||
channel->HasFlag(CHANNEL_FLAG_LFG));
if (sWorld->getBoolConfig(CONFIG_CHATLOG_SYSCHAN) && isSystem)
sLog->outChat("[SYSCHAN] Player %s tells channel %s: %s",
player->GetName().c_str(), channel->GetName().c_str(), msg.c_str());
else if (sWorld->getBoolConfig(CONFIG_CHATLOG_CHANNEL))
sLog->outChat("[CHANNEL] Player %s tells channel %s: %s",
player->GetName().c_str(), channel ? channel->GetName().c_str() : "<unknown>", msg.c_str());
if (isSystem)
{
LOG_CHAT("system", "Player %s tells channel %s: %s",
player->GetName().c_str(), channel->GetName().c_str(), msg.c_str());
}
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());
}
}
};

View File

@@ -274,7 +274,7 @@ bool EquippedOk(Player* player, uint32 spellId)
{
//player has item equipped that require specialty. Not allow to unlearn, player has to unequip first
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: player attempt to unlearn spell %u, but item %u is equipped.", reqSpell, item->GetEntry());
LOG_DEBUG("scripts.ai", "TSCR: player attempt to unlearn spell %u, but item %u is equipped.", reqSpell, item->GetEntry());
#endif
return false;
}

View File

@@ -503,14 +503,14 @@ public:
}
if (!SpawnAssoc)
sLog->outErrorDb("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 %u 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)
{
sLog->outErrorDb("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 %u does not exist in DB, which is required by npc_air_force_bots", SpawnAssoc->spawnedCreatureEntry);
SpawnAssoc = nullptr;
return;
}
@@ -530,7 +530,7 @@ public:
SpawnedGUID = summoned->GetGUID();
else
{
sLog->outErrorDb("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 %u", SpawnAssoc->spawnedCreatureEntry);
SpawnAssoc = nullptr;
}
@@ -1169,7 +1169,7 @@ void npc_doctor::npc_doctorAI::UpdateAI(uint32 diff)
patientEntry = HordeSoldierId[rand() % 3];
break;
default:
sLog->outError("TSCR: Invalid entry for Triage doctor. Please check your database");
LOG_ERROR("server", "TSCR: Invalid entry for Triage doctor. Please check your database");
return;
}