added time logging

This commit is contained in:
vaxerski
2022-07-18 11:46:42 +02:00
parent afeb040684
commit 60cc33a53c
3 changed files with 20 additions and 0 deletions

View File

@@ -41,6 +41,23 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
break;
}
// print date and time to the ofs
if (disableTime && !*disableTime) {
auto timet = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
const auto MILLIS = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() % 1000;
ofs << std::put_time(std::localtime(&timet), "[%H:%M:%S:");
if (MILLIS > 99)
ofs << MILLIS;
else if (MILLIS > 9)
ofs << "0" << MILLIS;
else
ofs << "00" << MILLIS;
ofs << "] ";
}
char buf[LOGMESSAGESIZE] = "";
char* outputStr;
int logLen;