1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 21:49:55 +00:00

[General] Move getFilenameTimestamp() to Utils

This commit is contained in:
Koncord 2017-11-07 05:33:10 +08:00
parent 0da44f69ad
commit d15c674584
5 changed files with 13 additions and 3 deletions

View file

@ -189,7 +189,7 @@ int main(int argc, char *argv[])
// Redirect cout and cerr to tes3mp server log // Redirect cout and cerr to tes3mp server log
logfile.open(boost::filesystem::path( logfile.open(boost::filesystem::path(
cfgMgr.getLogPath() / "/tes3mp-server-" += Log::getFilenameTimestamp() += ".log")); cfgMgr.getLogPath() / "/tes3mp-server-" += Utils::getFilenameTimestamp() += ".log"));
coutsb.open(Tee(logfile, oldcout)); coutsb.open(Tee(logfile, oldcout));
cerrsb.open(Tee(logfile, oldcerr)); cerrsb.open(Tee(logfile, oldcerr));

View file

@ -393,7 +393,7 @@ int main(int argc, char**argv)
that includes a timestamp that includes a timestamp
*/ */
// Redirect cout and cerr to tes3mp client log // 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) End of tes3mp change (major)
*/ */

View file

@ -48,7 +48,6 @@ public:
void SetLevel(int level); void SetLevel(int level);
void print(int level, bool hasPrefix, const char *file, int line, const char *message, ...) const; void print(int level, bool hasPrefix, const char *file, int line, const char *message, ...) const;
static std::string getFilenameTimestamp();
Log(const Log &) = delete; Log(const Log &) = delete;
Log &operator=(Log &) = delete; Log &operator=(Log &) = delete;

View file

@ -196,3 +196,12 @@ string Utils::intToHexStr(unsigned val)
sstr << "0x" << setfill('0') << setw(8) << uppercase << hex << val; sstr << "0x" << setfill('0') << setw(8) << uppercase << hex << val;
return sstr.str(); 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);
}

View file

@ -40,5 +40,7 @@ namespace Utils
void printWithWidth(std::ostringstream &sstr, std::string str, size_t width); void printWithWidth(std::ostringstream &sstr, std::string str, size_t width);
std::string intToHexStr(unsigned val); std::string intToHexStr(unsigned val);
std::string getFilenameTimestamp();
} }
#endif //UTILS_HPP #endif //UTILS_HPP