[General] Move getFilenameTimestamp() to Utils

new-script-api
Koncord 7 years ago
parent 0da44f69ad
commit d15c674584

@ -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));

@ -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)
*/

@ -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;

@ -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);
}

@ -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

Loading…
Cancel
Save