aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/debug
diff options
context:
space:
mode:
authorgiskard <[email protected]>2024-06-06 00:30:46 +0800
committerGitHub <[email protected]>2024-06-05 18:30:46 +0200
commitc95845b1488b4bd63e901cbdc4cb68c27a45971b (patch)
tree66988bb97251f28f06f136378baf21e827fdf999 /src/debug
parent82099fd1c0ab5b0bee022a45949556e7e1084835 (diff)
downloadHyprland-c95845b1488b4bd63e901cbdc4cb68c27a45971b.tar.gz
Hyprland-c95845b1488b4bd63e901cbdc4cb68c27a45971b.zip
log: log with local timezone (#6331)
* log: log with local timezone * log: backward compatability for clang 17 with libc++
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/Log.hpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/debug/Log.hpp b/src/debug/Log.hpp
index abf74065..e8cd80cf 100644
--- a/src/debug/Log.hpp
+++ b/src/debug/Log.hpp
@@ -49,11 +49,13 @@ namespace Debug {
// print date and time to the ofs
if (disableTime && !**disableTime) {
#ifndef _LIBCPP_VERSION
- logMsg += std::format("[{:%T}] ", std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())});
+ const auto zt = std::chrono::zoned_time{std::chrono::current_zone(), std::chrono::system_clock::now()};
+ const auto hms = std::chrono::hh_mm_ss{zt.get_local_time() - std::chrono::floor<std::chrono::days>(zt.get_local_time())};
#else
- auto c = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
- logMsg += std::format("{:%H}:{:%M}:{:%S}", c.hours(), c.minutes(), c.subseconds());
+ // TODO: current clang 17 does not support `zoned_time`, remove this once clang 19 is ready
+ const auto hms = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
#endif
+ logMsg += std::format("[{}] ", hms);
}
// no need for try {} catch {} because std::format_string<Args...> ensures that vformat never throw std::format_error