Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,18 @@ void logger_t::generate_common_prefix(std::string *str,
fmt::text_style const &ts,
char const *prefix) const
{
*str += fmt::format("{:%Y-%m-%d %H:%M:%S} ",
fmt::localtime(std::time(nullptr)));
auto const now = std::time(nullptr);
std::tm tm_local{};
#ifdef _MSC_VER
if (localtime_s(&tm_local, &now) != 0) {
throw fmt::format_error("time_t value out of range");
}
#else
if (!localtime_r(&now, &tm_local)) {
throw fmt::format_error("time_t value out of range");
}
#endif
*str += fmt::format("{:%F %T} ", tm_local);

if (m_current_level == log_level::debug) {
*str += fmt::format(ts, "[{:02d}] ", this_thread_num);
Expand Down
Loading