fix(Scripts/Chat): Fix chat logger (#17102)

* fix(Scripts/Chat): Fix chat logger

* Update chat_log.cpp

* Update worldserver.conf.dist

* Update chat_log.cpp

* fix build

* oopsie

* fix clang
This commit is contained in:
Kitzunu
2023-09-16 08:17:42 +02:00
committed by GitHub
parent edaf38c6c3
commit 66066f508b
5 changed files with 44 additions and 63 deletions

View File

@@ -19,12 +19,7 @@
#include "Group.h"
#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__);
#include "Log.h"
class ChatLogScript : public PlayerScript
{
@@ -36,66 +31,67 @@ public:
switch (type)
{
case CHAT_MSG_SAY:
LOG_CHAT("say", "Player {} says (language {}): {}",
LOG_INFO("chat.say", "Player {} says (language {}): {}",
player->GetName(), lang, msg);
break;
case CHAT_MSG_EMOTE:
LOG_CHAT("emote", "Player {} emotes: {}",
LOG_INFO("chat.emote", "Player {} emotes: {}",
player->GetName(), msg);
break;
case CHAT_MSG_YELL:
LOG_CHAT("yell", "Player {} yells (language {}): {}",
LOG_INFO("chat.yell", "Player {} yells (language {}): {}",
player->GetName(), lang, msg);
break;
}
}
void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver) override
void OnChat(Player* player, uint32 /*type*/, uint32 /*lang*/, std::string& msg, Player* receiver) override
{
LOG_CHAT("whisper", "Player {} tells {}: {}",
LOG_INFO("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
{
std::string str = lang != LANG_ADDON ? "chat." : "chat.addon.";
//! NOTE:
//! LANG_ADDON can only be sent by client in "PARTY", "RAID", "GUILD", "BATTLEGROUND", "WHISPER"
switch (type)
{
case CHAT_MSG_PARTY:
LOG_CHAT("party", "Player {} tells group with leader {}: {}",
LOG_INFO(str + "party", "Player {} tells group with leader {}: {}",
player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg);
break;
case CHAT_MSG_PARTY_LEADER:
LOG_CHAT("party", "Leader {} tells group: {}",
LOG_INFO(str + "party", "Leader {} tells group: {}",
player->GetName(), msg);
break;
case CHAT_MSG_RAID:
LOG_CHAT("raid", "Player {} tells raid with leader {}: {}",
LOG_INFO(str + "raid", "Player {} tells raid with leader {}: {}",
player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg);
break;
case CHAT_MSG_RAID_LEADER:
LOG_CHAT("raid", "Leader player {} tells raid: {}",
LOG_INFO(str + "raid", "Leader player {} tells raid: {}",
player->GetName(), msg);
break;
case CHAT_MSG_RAID_WARNING:
LOG_CHAT("raid", "Leader player {} warns raid with: {}",
LOG_INFO(str + "raid", "Leader player {} sends raid warning: {}",
player->GetName(), msg);
break;
case CHAT_MSG_BATTLEGROUND:
LOG_CHAT("bg", "Player {} tells battleground with leader {}: {}",
LOG_INFO(str + "bg", "Player {} tells battleground with leader {}: {}",
player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg);
break;
case CHAT_MSG_BATTLEGROUND_LEADER:
LOG_CHAT("bg", "Leader player {} tells battleground: {}",
LOG_INFO(str + "bg", "Leader player {} tells battleground: {}",
player->GetName(), msg);
break;
}
@@ -103,21 +99,22 @@ public:
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild) override
{
std::string str = lang != LANG_ADDON ? "chat." : "chat.addon.";
switch (type)
{
case CHAT_MSG_GUILD:
LOG_CHAT("guild", "Player {} tells guild {}: {}",
LOG_INFO(str + "guild", "Player {} tells guild {}: {}",
player->GetName(), guild ? guild->GetName() : "<unknown>", msg);
break;
case CHAT_MSG_OFFICER:
LOG_CHAT("guild.officer", "Player {} tells guild {} officers: {}",
LOG_INFO(str + "guild.officer", "Player {} tells guild {} officers: {}",
player->GetName(), guild ? guild->GetName() : "<unknown>", msg);
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) ||
@@ -127,13 +124,15 @@ public:
if (isSystem)
{
LOG_CHAT("system", "Player {} tells channel {}: {}",
LOG_INFO("chat.channel", "Player {} tells channel {}: {}",
player->GetName(), channel->GetName(), msg);
}
else
{
// Allow to log custom channels. i.e. world channel
// in that case set config: Logger.channel.world=6,Chat
std::string channelName = channel ? channel->GetName() : "<unknown>";
LOG_CHAT("channel." + channelName, "Player {} tells channel {}: {}",
LOG_INFO("chat.channel." + channelName, "Player {} tells channel {}: {}",
player->GetName(), channelName, msg);
}
}