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/shared/Log.cpp | |
parent | a2381b9863d388878eaa199912dee8fc4f83afd6 (diff) |
Dump characters to separate files config option, by azazel.kon
Resolves #744
--HG--
branch : trunk
Diffstat (limited to 'src/shared/Log.cpp')
-rw-r--r-- | src/shared/Log.cpp | 35 |
1 files changed, 27 insertions, 8 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); } } |