aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/Log.cpp29
-rw-r--r--src/shared/Log.h4
2 files changed, 33 insertions, 0 deletions
diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp
index 9f7167f9238..401394af1a5 100644
--- a/src/shared/Log.cpp
+++ b/src/shared/Log.cpp
@@ -95,6 +95,7 @@ void Log::Initialize()
m_dbChar = sConfig.GetBoolDefault("LogDB.Char", false);
m_dbRA = sConfig.GetBoolDefault("LogDB.RA", false);
m_dbGM = sConfig.GetBoolDefault("LogDB.GM", false);
+ m_dbChat = sConfig.GetBoolDefault("LogDB.Chat", false);
/// Common log files data
m_logsDir = sConfig.GetStringDefault("LogsDir","");
@@ -145,6 +146,7 @@ void Log::Initialize()
dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
raLogfile = openLogFile("RaLogFile",NULL,"a");
+ chatLogfile = openLogFile("ChatLogFile",NULL,"a");
// Main log file settings
m_logLevel = sConfig.GetIntDefault("LogLevel", LOGL_NORMAL);
@@ -796,6 +798,33 @@ void Log::outRemote( const char * str, ... )
fflush(stdout);
}
+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)
+ {
+ va_list ap;
+ va_start(ap, str);
+ vfprintf(chatLogfile, str, ap);
+ fprintf(chatLogfile, "\n" );
+ fflush(chatLogfile);
+ va_end(ap);
+ }
+ fflush(stdout);
+}
+
void outstring_log(const char * str, ...)
{
if( !str )
diff --git a/src/shared/Log.h b/src/shared/Log.h
index a82b5a6a068..a0220b1bce7 100644
--- a/src/shared/Log.h
+++ b/src/shared/Log.h
@@ -47,6 +47,7 @@ enum LogTypes
LOG_TYPE_RA = 7,
LOG_TYPE_GM = 8,
LOG_TYPE_CRASH = 9,
+ LOG_TYPE_CHAT = 10,
MAX_LOG_TYPES
};
@@ -106,6 +107,7 @@ class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ZThr
void outChar( const char * str, ... ) ATTR_PRINTF(2,3);
void outCommand( uint32 account, const char * str, ...) ATTR_PRINTF(3,4);
void outRemote( const char * str, ... ) ATTR_PRINTF(2,3);
+ void outChat( const char * str, ... ) ATTR_PRINTF(2,3);
void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name );
static void outTimestamp(FILE* file);
@@ -133,6 +135,7 @@ class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ZThr
FILE* gmLogfile;
FILE* charLogfile;
FILE* dberLogfile;
+ FILE* chatLogfile;
// cache values for after initilization use (like gm log per account case)
std::string m_logsDir;
@@ -159,6 +162,7 @@ class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ZThr
bool m_dbChar;
bool m_dbRA;
bool m_dbGM;
+ bool m_dbChat;
bool m_charLog_Dump;
};