Use localtime_r
This commit is contained in:
parent
9e73720525
commit
04c46e220f
3
log.cpp
3
log.cpp
|
@ -16,8 +16,9 @@ LogEntry::LogEntry(time_t time_, std::string message_) : time(time_), message(st
|
|||
|
||||
|
||||
std::string format_log(const LogEntry& entry) {
|
||||
struct tm tm;
|
||||
char time_as_str[128] = {0};
|
||||
strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&entry.time));
|
||||
strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&entry.time, &tm));
|
||||
return std::string(1, '[') + time_as_str + "] " + entry.message;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,9 @@ static inline void render_table(ImFont* monospace_font, bool* autoscrolling) {
|
|||
size_t i = static_cast<size_t>(i_u);
|
||||
|
||||
const LogEntry* log_entry = &log_entries[i];
|
||||
struct tm tm;
|
||||
char time_as_str[128] = {0};
|
||||
strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&log_entry->time));
|
||||
strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&log_entry->time, &tm));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str);
|
||||
|
|
|
@ -27,8 +27,9 @@ static inline void render_table(ImFont* monospace_font, std::vector<LogcatEntry>
|
|||
while (clipper.Step()) {
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
const LogcatEntry* logcat_entry = &logcat_entries[filtered_logcat_entry_offsets[static_cast<size_t>(i)]];
|
||||
struct tm tm;
|
||||
char time_as_str[128] = {0};
|
||||
strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&logcat_entry->time));
|
||||
strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&logcat_entry->time, &tm));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str);
|
||||
|
|
Loading…
Reference in New Issue