diff options
author | vaxerski <[email protected]> | 2022-07-18 11:46:42 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-07-18 11:46:42 +0200 |
commit | 60cc33a53cd401be92673c144eaa67555525933e (patch) | |
tree | 22c9ea3e3a815bcc35d17bcde8e4e86575965ed9 /src/debug/Log.cpp | |
parent | afeb040684017dfb27ca3cb3823e41dd95310af1 (diff) | |
download | Hyprland-60cc33a53cd401be92673c144eaa67555525933e.tar.gz Hyprland-60cc33a53cd401be92673c144eaa67555525933e.zip |
added time logging
Diffstat (limited to 'src/debug/Log.cpp')
-rw-r--r-- | src/debug/Log.cpp | 17 |
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; |