Fix log file path corruption on windows

This commit is contained in:
Phillip Stephens 2020-12-25 22:00:26 -08:00
parent 27990a344a
commit 0364d50164
1 changed files with 2 additions and 2 deletions

View File

@ -170,12 +170,12 @@ int main(int argc, const boo::SystemChar** argv)
args.push_back(argv[i]); args.push_back(argv[i]);
cvarMgr.parseCommandLine(args); cvarMgr.parseCommandLine(args);
hecl::SystemStringView logFile = hecl::SystemStringConv(cvarCmns.getLogFile()).sys_str(); hecl::SystemString logFile{hecl::SystemStringConv(cvarCmns.getLogFile()).c_str()};
hecl::SystemString logFilePath; hecl::SystemString logFilePath;
if (!logFile.empty()) { if (!logFile.empty()) {
std::time_t time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); std::time_t time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
char buf[100]; char buf[100];
std::strftime(buf, 100, "%Y-%m-%d_%H-%M-%S", std::localtime(&time)); std::strftime(buf, 100, "%Y-%m-%d_%H-%M-%S\0", std::localtime(&time));
hecl::SystemString timeStr = hecl::SystemStringConv(buf).c_str(); hecl::SystemString timeStr = hecl::SystemStringConv(buf).c_str();
logFilePath = fmt::format(FMT_STRING(_SYS_STR("{}/{}-{}")), fileMgr.getStoreRoot(), timeStr, logFile); logFilePath = fmt::format(FMT_STRING(_SYS_STR("{}/{}-{}")), fileMgr.getStoreRoot(), timeStr, logFile);
logvisor::RegisterFileLogger(logFilePath.c_str()); logvisor::RegisterFileLogger(logFilePath.c_str());