summaryrefslogtreecommitdiff
path: root/src/debug/Log.cpp
diff options
context:
space:
mode:
authorDarksome <dev@darkso.me>2022-07-21 19:18:03 +0300
committerDarksome <dev@darkso.me>2022-07-21 19:18:03 +0300
commiteb8a1939e6dddaaf81f6b623d1c657b801978487 (patch)
treed62d4ca30d4114fe2e2745e36907b65ac4be20af /src/debug/Log.cpp
parent68cfc1a496f556f360c032651b75d33ddb576517 (diff)
parent7f660fed0d4a8133ccde21c3e092dbc8c6e08c60 (diff)
Merge upstream
Diffstat (limited to 'src/debug/Log.cpp')
-rw-r--r--src/debug/Log.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/debug/Log.cpp b/src/debug/Log.cpp
index 2fa4a127..59d2d239 100644
--- a/src/debug/Log.cpp
+++ b/src/debug/Log.cpp
@@ -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;