diff options
author | Tartalo <none@none> | 2010-02-23 00:05:10 +0100 |
---|---|---|
committer | Tartalo <none@none> | 2010-02-23 00:05:10 +0100 |
commit | c6bdcb6b7c4432df0efa686bda3f8dbff53a905d (patch) | |
tree | 3e42e0ff381be139c4d334a4da65a84e455f3f14 /src | |
parent | a2381b9863d388878eaa199912dee8fc4f83afd6 (diff) |
Dump characters to separate files config option, by azazel.kon
Resolves #744
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/Log.cpp | 35 | ||||
-rw-r--r-- | src/shared/Log.h | 2 | ||||
-rw-r--r-- | src/trinitycore/trinitycore.conf.dist | 19 |
3 files changed, 47 insertions, 9 deletions
diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp index ab4da70468a..811a2c7c3fe 100644 --- a/src/shared/Log.cpp +++ b/src/shared/Log.cpp @@ -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); } } diff --git a/src/shared/Log.h b/src/shared/Log.h index a6832bff61f..deb6c55e4e0 100644 --- a/src/shared/Log.h +++ b/src/shared/Log.h @@ -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() diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist index 06bf10e49ad..a4202a24a84 100644 --- a/src/trinitycore/trinitycore.conf.dist +++ b/src/trinitycore/trinitycore.conf.dist @@ -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 |