We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6ce2bc0 + dec2937 commit 6c96199Copy full SHA for 6c96199
src/logging.cpp
@@ -27,8 +27,18 @@ void logger_t::generate_common_prefix(std::string *str,
27
fmt::text_style const &ts,
28
char const *prefix) const
29
{
30
- *str += fmt::format("{:%Y-%m-%d %H:%M:%S} ",
31
- fmt::localtime(std::time(nullptr)));
+ auto const now = std::time(nullptr);
+ std::tm tm_local{};
32
+#ifdef _MSC_VER
33
+ if (localtime_s(&tm_local, &now) != 0) {
34
+ throw fmt::format_error("time_t value out of range");
35
+ }
36
+#else
37
+ if (!localtime_r(&now, &tm_local)) {
38
39
40
+#endif
41
+ *str += fmt::format("{:%F %T} ", tm_local);
42
43
if (m_current_level == log_level::debug) {
44
*str += fmt::format(ts, "[{:02d}] ", this_thread_num);
0 commit comments