Core/Logging: Re-Implemented onChat scripting system
This commit is contained in:
parent
c0590a5cfc
commit
3b2fb0949b
11 changed files with 303 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ extern LoginDatabaseWorkerPool LoginDatabase;
|
|||
|
||||
Log::Log() :
|
||||
raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
|
||||
dberLogfile(NULL), sqlLogFile(NULL), sqlDevLogFile(NULL), miscLogFile(NULL),
|
||||
dberLogfile(NULL), chatLogfile(NULL), sqlLogFile(NULL), sqlDevLogFile(NULL), miscLogFile(NULL),
|
||||
m_gmlog_per_account(false), m_enableLogDB(false), m_colored(false)
|
||||
{
|
||||
Initialize();
|
||||
|
|
@ -48,6 +48,10 @@ Log::~Log()
|
|||
fclose(raLogfile);
|
||||
raLogfile = NULL;
|
||||
|
||||
if (chatLogfile != NULL)
|
||||
fclose(chatLogfile);
|
||||
chatLogfile = NULL;
|
||||
|
||||
if (sqlLogFile != NULL)
|
||||
fclose(sqlLogFile);
|
||||
sqlLogFile = NULL;
|
||||
|
|
@ -87,6 +91,7 @@ void Log::Initialize()
|
|||
m_dbChar = sConfigMgr->GetBoolDefault("LogDB.Char", false);
|
||||
m_dbRA = sConfigMgr->GetBoolDefault("LogDB.RA", false);
|
||||
m_dbGM = sConfigMgr->GetBoolDefault("LogDB.GM", false);
|
||||
m_dbChat = sConfigMgr->GetBoolDefault("LogDB.Chat", false);
|
||||
|
||||
/// Realm must be 0 by default
|
||||
SetRealmID(0);
|
||||
|
|
@ -137,6 +142,7 @@ void Log::Initialize()
|
|||
charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a");
|
||||
dberLogfile = openLogFile("DBErrorLogFile", NULL, "a");
|
||||
raLogfile = openLogFile("RaLogFile", NULL, "a");
|
||||
chatLogfile = openLogFile("ChatLogFile", "ChatLogTimestamp", "a");
|
||||
sqlLogFile = openLogFile("SQLDriverLogFile", NULL, "a");
|
||||
sqlDevLogFile = openLogFile("SQLDeveloperLogFile", NULL, "a");
|
||||
miscLogFile = fopen((m_logsDir+"Misc.log").c_str(), "a");
|
||||
|
|
@ -922,6 +928,33 @@ void Log::outCharDump(const char * str, uint32 account_id, uint32 guid, const ch
|
|||
}
|
||||
}
|
||||
|
||||
void Log::outChat(const char * str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
if (m_enableLogDB && m_dbChat)
|
||||
{
|
||||
va_list ap2;
|
||||
va_start(ap2, str);
|
||||
char nnew_str[MAX_QUERY_LEN];
|
||||
vsnprintf(nnew_str, MAX_QUERY_LEN, str, ap2);
|
||||
outDB(LOG_TYPE_CHAT, nnew_str);
|
||||
va_end(ap2);
|
||||
}
|
||||
|
||||
if (chatLogfile)
|
||||
{
|
||||
outTimestamp(chatLogfile);
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
vfprintf(chatLogfile, str, ap);
|
||||
fprintf(chatLogfile, "\n");
|
||||
fflush(chatLogfile);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
void Log::outRemote(const char * str, ...)
|
||||
{
|
||||
if (!str)
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ class Log
|
|||
void outErrorDb(const char * str, ...) ATTR_PRINTF(2, 3);
|
||||
void outChar(const char * str, ...) ATTR_PRINTF(2, 3);
|
||||
void outCommand(uint32 account, const char * str, ...) ATTR_PRINTF(3, 4);
|
||||
void outChat(const char * str, ...) ATTR_PRINTF(2, 3);
|
||||
void outRemote(const char * str, ...) ATTR_PRINTF(2, 3);
|
||||
void outSQLDriver(const char* str, ...) ATTR_PRINTF(2, 3);
|
||||
void outMisc(const char * str, ...) ATTR_PRINTF(2, 3); // pussywizard
|
||||
|
|
@ -151,6 +152,7 @@ class Log
|
|||
FILE* gmLogfile;
|
||||
FILE* charLogfile;
|
||||
FILE* dberLogfile;
|
||||
FILE* chatLogfile;
|
||||
FILE* sqlLogFile;
|
||||
FILE* sqlDevLogFile;
|
||||
FILE* miscLogFile;
|
||||
|
|
@ -182,6 +184,7 @@ class Log
|
|||
bool m_dbChar;
|
||||
bool m_dbRA;
|
||||
bool m_dbGM;
|
||||
bool m_dbChat;
|
||||
bool m_charLog_Dump;
|
||||
bool m_charLog_Dump_Separate;
|
||||
std::string m_dumpsDir;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue