diff --git a/modules/log.cpp b/modules/log.cpp index 2f3124a3..b7f8cc1e 100644 --- a/modules/log.cpp +++ b/modules/log.cpp @@ -106,6 +106,7 @@ public: private: CString m_sLogPath; + CString m_sTimestamp; bool m_bSanitize; vector m_vRules; }; @@ -268,15 +269,35 @@ CString CLogMod::GetServer() bool CLogMod::OnLoad(const CString& sArgs, CString& sMessage) { - size_t uIndex = 0; - if (sArgs.Token(0).Equals("-sanitize")) - { - m_bSanitize = true; - ++uIndex; + VCString vsArgs; + sArgs.Split(" ", vsArgs); + + bool bHaveTimestamp = false; + bool bHaveLogPath = false; + for (CString& sArg : vsArgs) { + if (sArg.Equals("-sanitize")) { + m_bSanitize = true; + } else if (sArg.Equals("-timestamp")) { + // Everything after this must be timestamp + bHaveTimestamp = true; + } else { + if (bHaveTimestamp) { + m_sTimestamp += sArg + " "; + } else { + // Only one arg may be LogPath + if (bHaveLogPath) { + sMessage = "Invalid args [" + sArgs + "]. Only one log path allowed. Check that there are no spaces in the path."; + return false; + } + m_sLogPath = sArg; + bHaveLogPath = true; + } + } } - // Use load parameter as save path - m_sLogPath = sArgs.Token(uIndex); + if (m_sTimestamp.empty()) { + m_sTimestamp = "[%H:%M:%S] "; + } // Add default filename to path if it's a folder if (GetType() == CModInfo::UserModule) { @@ -313,7 +334,7 @@ bool CLogMod::OnLoad(const CString& sArgs, CString& sMessage) sMessage = "Invalid log path ["+m_sLogPath+"]."; return false; } else { - sMessage = "Logging to ["+m_sLogPath+"]."; + sMessage = "Logging to ["+m_sLogPath+"]. Using timestamp ["+m_sTimestamp+"]"; return true; } }