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

@@ -398,6 +398,4 @@ void Log::LoadFromConfig()
ReadAppendersFromConfig();
ReadLoggersFromConfig();
_debugLogMask = DebugLogFilters(sConfigMgr->GetOption<uint32>("DebugLogMask", LOG_FILTER_NONE, false));
}

View File

@@ -121,8 +121,6 @@ private:
Acore::Asio::IoContext* _ioContext;
Acore::Asio::Strand* _strand;
// Deprecated debug filter logs
DebugLogFilters _debugLogMask;
};
#define sLog Log::instance()

View File

@@ -46,6 +46,7 @@ enum AppenderType : uint8
APPENDER_INVALID = 0xFF // SKIP
};
// EnumUtils: DESCRIBE THIS
enum AppenderFlags : uint8
{
APPENDER_FLAGS_NONE = 0x00,
@@ -56,37 +57,4 @@ enum AppenderFlags : uint8
APPENDER_FLAGS_MAKE_FILE_BACKUP = 0x10
};
// Dprecated debug log filters need delte later
enum DebugLogFilters
{
LOG_FILTER_NONE = 0x00000000,
LOG_FILTER_UNITS = 0x00000001, // Anything related to units that doesn't fit in other categories. ie. creature formations
LOG_FILTER_PETS = 0x00000002,
LOG_FILTER_VEHICLES = 0x00000004,
LOG_FILTER_TSCR = 0x00000008, // C++ AI, instance scripts, etc.
LOG_FILTER_DATABASE_AI = 0x00000010, // SmartAI, EventAI, CreatureAI
LOG_FILTER_MAPSCRIPTS = 0x00000020,
LOG_FILTER_NETWORKIO = 0x00000040, // Anything packet/netcode related
LOG_FILTER_SPELLS_AURAS = 0x00000080,
LOG_FILTER_ACHIEVEMENTSYS = 0x00000100,
LOG_FILTER_CONDITIONSYS = 0x00000200,
LOG_FILTER_POOLSYS = 0x00000400,
LOG_FILTER_AUCTIONHOUSE = 0x00000800,
LOG_FILTER_BATTLEGROUND = 0x00001000, // Anything related to arena's and battlegrounds
LOG_FILTER_OUTDOORPVP = 0x00002000,
LOG_FILTER_CHATSYS = 0x00004000,
LOG_FILTER_LFG = 0x00008000,
LOG_FILTER_MAPS = 0x00010000, // Maps, instances, grids, cells, visibility
LOG_FILTER_PLAYER_LOADING = 0x00020000, // Debug output from Player::_Load functions
LOG_FILTER_PLAYER_ITEMS = 0x00040000, // Anything item related
LOG_FILTER_PLAYER_SKILLS = 0x00080000, // Skills related
LOG_FILTER_LOOT = 0x00100000, // Loot related
LOG_FILTER_GUILD = 0x00200000, // Guild related
LOG_FILTER_TRANSPORTS = 0x00400000, // Transport related
LOG_FILTER_WARDEN = 0x00800000, // Warden related
LOG_FILTER_BATTLEFIELD = 0x01000000, // Battlefield related
LOG_FILTER_MODULES = 0x02000000, // Modules debug
LOG_FILTER_CLOSE_SOCKET = 0x04000000, // Whenever KickPlayer() or CloseSocket() are called
};
#endif // LogCommon_h__

View File

@@ -3949,6 +3949,7 @@ AuctionHouse.SearchTimeout = 1000
Appender.Console=1,4,0,"1 9 3 6 5 8"
Appender.Server=2,5,0,Server.log,w
# Appender.Chat=2,4,15,chat_%s.log
# Appender.GM=2,5,15,gm_%s.log
Appender.Errors=2,5,0,Errors.log
# Appender.DB=3,5,0
@@ -3993,9 +3994,26 @@ Logger.spells.scripts=2,Console Errors
#Logger.bg.battleground=4,Console Server
#Logger.bg.reportpvpafk=4,Console Server
#Logger.calendar=4,Console Server
#Logger.chat.log=4,Console Server
#Logger.chat.log.addon=4,Console Server
#Logger.chat.system=4,Console Server
#Logger.chat.say=4,Console Chat
#Logger.chat.emote=4,Console Chat
#Logger.chat.yell=4,Console Chat
#Logger.chat.whisper=4,Console Chat
#Logger.chat.party=4,Console Chat
#Logger.chat.raid=4,Console Chat
#Logger.chat.bg=4,Console Chat
#Logger.chat.guild=4,Console Chat
#Logger.chat.guild.officer=4,Console Chat
#Logger.chat.channel=4,Console Chat
#Logger.chat.addon.msg=4,Console Chat
#Logger.chat.addon.emote=4,Console Chat
#Logger.chat.addon.yell=4,Console Chat
#Logger.chat.addon.whisper=4,Console Chat
#Logger.chat.addon.party=4,Console Chat
#Logger.chat.addon.raid=4,Console Chat
#Logger.chat.addon.bg=4,Console Chat
#Logger.chat.addon.guild=4,Console Chat
#Logger.chat.addon.guild.officer=4,Console Chat
#Logger.chat.addon.channel=4,Console Chat
#Logger.cheat=4,Console Server
#Logger.commands.ra=4,Console Server
#Logger.condition=4,Console Server

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);
}
}