mirror of
https://github.com/gabime/spdlog.git
synced 2025-02-05 04:06:46 +08:00
Make err_helper time printing more robust
This commit is contained in:
parent
35060923d9
commit
214e26e8b2
@ -35,8 +35,10 @@ void err_helper::handle_ex(const std::string &origin, const source_loc &loc, con
|
|||||||
}
|
}
|
||||||
last_report_time_ = now;
|
last_report_time_ = now;
|
||||||
const auto tm_time = os::localtime();
|
const auto tm_time = os::localtime();
|
||||||
char date_buf[32];
|
char date_buf[64];
|
||||||
std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time);
|
if (std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time) == 0) {
|
||||||
|
std::snprintf(date_buf, sizeof(date_buf), "unknown time");
|
||||||
|
}
|
||||||
std::string msg;
|
std::string msg;
|
||||||
if (loc.empty()) {
|
if (loc.empty()) {
|
||||||
msg = fmt_lib::format("[*** LOG ERROR ***] [{}] [{}] {}\n", date_buf, origin, ex.what());
|
msg = fmt_lib::format("[*** LOG ERROR ***] [{}] [{}] {}\n", date_buf, origin, ex.what());
|
||||||
|
Loading…
Reference in New Issue
Block a user