mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 16:10:49 +01:00
Dump characters to separate files config option, by azazel.kon
Resolves #744 --HG-- branch : trunk
This commit is contained in:
@@ -111,11 +111,9 @@ void Log::Initialize()
|
||||
|
||||
/// Common log files data
|
||||
m_logsDir = sConfig.GetStringDefault("LogsDir","");
|
||||
if(!m_logsDir.empty())
|
||||
{
|
||||
if((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
|
||||
if (!m_logsDir.empty())
|
||||
if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
|
||||
m_logsDir.append("/");
|
||||
}
|
||||
|
||||
m_logsTimestamp = "_" + GetTimestampStr();
|
||||
|
||||
@@ -179,7 +177,14 @@ void Log::Initialize()
|
||||
|
||||
// Char log settings
|
||||
m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false);
|
||||
|
||||
m_charLog_Dump_Separate = sConfig.GetBoolDefault("CharLogDump.Separate", false);
|
||||
if (m_charLog_Dump_Separate)
|
||||
{
|
||||
m_dumpsDir = sConfig.GetStringDefault("CharLogDump.SeparateDir", "");
|
||||
if (!m_dumpsDir.empty())
|
||||
if ((m_dumpsDir.at(m_dumpsDir.length() - 1) != '/') && (m_dumpsDir.at(m_dumpsDir.length() - 1) != '\\'))
|
||||
m_dumpsDir.append("/");
|
||||
}
|
||||
}
|
||||
|
||||
FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode)
|
||||
@@ -850,10 +855,24 @@ void Log::outChar(const char * str, ...)
|
||||
|
||||
void Log::outCharDump(const char * str, uint32 account_id, uint32 guid, const char * name)
|
||||
{
|
||||
if (charLogfile)
|
||||
FILE *file = NULL;
|
||||
if (m_charLog_Dump_Separate)
|
||||
{
|
||||
fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n",account_id,guid,name,str );
|
||||
fflush(charLogfile);
|
||||
char fileName[29]; // Max length: name(12) + guid(11) + _.log (5) + \0
|
||||
snprintf(fileName, 29, "%d_%s.log", guid, name);
|
||||
std::string sFileName(m_dumpsDir);
|
||||
sFileName.append(fileName);
|
||||
file = fopen((m_logsDir + sFileName).c_str(), "w");
|
||||
}
|
||||
else
|
||||
file = charLogfile;
|
||||
if (file)
|
||||
{
|
||||
fprintf(file, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n",
|
||||
account_id, guid, name, str);
|
||||
fflush(file);
|
||||
if (m_charLog_Dump_Separate)
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,8 @@ class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ACE_
|
||||
bool m_dbGM;
|
||||
bool m_dbChat;
|
||||
bool m_charLog_Dump;
|
||||
bool m_charLog_Dump_Separate;
|
||||
std::string m_dumpsDir;
|
||||
};
|
||||
|
||||
#define sLog Trinity::Singleton<Log>::Instance()
|
||||
|
||||
@@ -321,6 +321,14 @@ MapUpdate.Threads = 1
|
||||
# and load it using the loadpdump command
|
||||
# Default: 0 - don't include dumping chars to log
|
||||
# 1 - include dumping chars to log
|
||||
# CharLogDump.Separate
|
||||
# Write character dump to separate file
|
||||
# Default: 0 - don't write dump to separate file
|
||||
# 1 - write each dump to separate file
|
||||
#
|
||||
# CharLogDump.SeparateDir
|
||||
# Subdirectory within logs dir for separate char dumps.
|
||||
#
|
||||
#
|
||||
# GmLogFile
|
||||
# Log file of gm commands
|
||||
@@ -378,7 +386,14 @@ MapUpdate.Threads = 1
|
||||
# DBLogLevel
|
||||
# Log level of DB logging.
|
||||
# 0 = Minimum
|
||||
# 1 = Basic
|
||||
# 1 = Basic+# CharLogDump.Separate
|
||||
+# Write character dump to separate file
|
||||
+# Default: 0 - don't write dump to separate file
|
||||
+# 1 - write each dump to separate file
|
||||
+#
|
||||
+# CharLogDump.SeparateDir
|
||||
+# Subdirectory within logs dir for separate char dumps.
|
||||
+#
|
||||
# 2 = Detail
|
||||
# Default: 3 = Full/Debug
|
||||
#
|
||||
@@ -471,6 +486,8 @@ DBErrorLogFile = "db_errors.log"
|
||||
CharLogFile = "characters.log"
|
||||
CharLogTimestamp = 0
|
||||
CharLogDump = 0
|
||||
CharLogDump.Separate = 0
|
||||
CharLogDump.SeparateDir = ""
|
||||
GmLogFile = "gm_commands.log"
|
||||
GmLogTimestamp = 0
|
||||
GmLogPerAccount = 0
|
||||
|
||||
Reference in New Issue
Block a user