fix time format string for use with MinGW; use std::chrono::system_clock
This commit is contained in:
parent
21471c13c0
commit
d403a32766
13
Log.cpp
13
Log.cpp
|
@ -161,11 +161,16 @@ void Entry::addMetadataHeader() {
|
|||
static const char* LevelTag[] = {"", "[FATAL] ", "[ERROR] ", "[WARN ] ",
|
||||
"[NOTE ] ", "[INFO ] ", "[DEBUG] ", "[TRACE] "};
|
||||
|
||||
// get current date/time
|
||||
std::time_t now = std::time(NULL);
|
||||
|
||||
// datetime
|
||||
ss << "[" << std::put_time(std::localtime(&now), "%F %T") << "]";
|
||||
using namespace std::chrono;
|
||||
auto now = system_clock::to_time_t(system_clock::now());
|
||||
auto tm = *std::localtime(&now);
|
||||
|
||||
// MinGW doesn't support the ISO8601 formatting characters like "%F" and "%T"
|
||||
// ref: https://sourceforge.net/p/mingw-w64/bugs/793/
|
||||
// Therefore, use a more verbose time string
|
||||
ss << "[" << std::put_time(&tm, "%Y-%m-%d %H:%M:%S") << "]";
|
||||
|
||||
// log level
|
||||
ss << LevelTag[lvl];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue