diff --git a/apps/openmw-mp/main.cpp b/apps/openmw-mp/main.cpp index 96af274cc..79037a2b8 100644 --- a/apps/openmw-mp/main.cpp +++ b/apps/openmw-mp/main.cpp @@ -189,7 +189,7 @@ int main(int argc, char *argv[]) // Redirect cout and cerr to tes3mp server log logfile.open(boost::filesystem::path( - cfgMgr.getLogPath() / "/tes3mp-server-" += Log::getFilenameTimestamp() += ".log")); + cfgMgr.getLogPath() / "/tes3mp-server-" += Utils::getFilenameTimestamp() += ".log")); coutsb.open(Tee(logfile, oldcout)); cerrsb.open(Tee(logfile, oldcerr)); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index d482dcf6d..328cdef55 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -393,7 +393,7 @@ int main(int argc, char**argv) that includes a timestamp */ // Redirect cout and cerr to tes3mp client log - logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / "/tes3mp-client-" += Log::getFilenameTimestamp() += ".log")); + logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / "/tes3mp-client-" += Utils::getFilenameTimestamp() += ".log")); /* End of tes3mp change (major) */ diff --git a/components/openmw-mp/Log.hpp b/components/openmw-mp/Log.hpp index c2a648037..54e834570 100644 --- a/components/openmw-mp/Log.hpp +++ b/components/openmw-mp/Log.hpp @@ -48,7 +48,6 @@ public: void SetLevel(int level); void print(int level, bool hasPrefix, const char *file, int line, const char *message, ...) const; - static std::string getFilenameTimestamp(); Log(const Log &) = delete; Log &operator=(Log &) = delete; diff --git a/components/openmw-mp/Utils.cpp b/components/openmw-mp/Utils.cpp index a4a4b6e7b..bba0c47ac 100644 --- a/components/openmw-mp/Utils.cpp +++ b/components/openmw-mp/Utils.cpp @@ -196,3 +196,12 @@ string Utils::intToHexStr(unsigned val) sstr << "0x" << setfill('0') << setw(8) << uppercase << hex << val; return sstr.str(); } + +string Utils::getFilenameTimestamp() +{ + time_t rawtime = time(nullptr); + struct tm *timeinfo = localtime(&rawtime); + char buffer[25]; + strftime(buffer, 25, "%Y-%m-%d-%H_%M_%S", timeinfo); + return string(buffer); +} diff --git a/components/openmw-mp/Utils.hpp b/components/openmw-mp/Utils.hpp index 448cb13d7..47e264358 100644 --- a/components/openmw-mp/Utils.hpp +++ b/components/openmw-mp/Utils.hpp @@ -40,5 +40,7 @@ namespace Utils void printWithWidth(std::ostringstream &sstr, std::string str, size_t width); std::string intToHexStr(unsigned val); + + std::string getFilenameTimestamp(); } #endif //UTILS_HPP