mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 00:45:58 +01:00
log: log with local timezone (#6331)
* log: log with local timezone * log: backward compatability for clang 17 with libc++
This commit is contained in:
parent
82099fd1c0
commit
c95845b148
1 changed files with 5 additions and 3 deletions
|
@ -49,11 +49,13 @@ namespace Debug {
|
||||||
// print date and time to the ofs
|
// print date and time to the ofs
|
||||||
if (disableTime && !**disableTime) {
|
if (disableTime && !**disableTime) {
|
||||||
#ifndef _LIBCPP_VERSION
|
#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
|
#else
|
||||||
auto c = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
|
// TODO: current clang 17 does not support `zoned_time`, remove this once clang 19 is ready
|
||||||
logMsg += std::format("{:%H}:{:%M}:{:%S}", c.hours(), c.minutes(), c.subseconds());
|
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
|
#endif
|
||||||
|
logMsg += std::format("[{}] ", hms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need for try {} catch {} because std::format_string<Args...> ensures that vformat never throw std::format_error
|
// no need for try {} catch {} because std::format_string<Args...> ensures that vformat never throw std::format_error
|
||||||
|
|
Loading…
Reference in a new issue