Skip to content

Commit

Permalink
Merge pull request #37 from RolfJordi/add_time_log_image
Browse files Browse the repository at this point in the history
Add time log image
  • Loading branch information
anirul authored Mar 30, 2024
2 parents bca13af + cdf0910 commit 2c66763
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/frame/gui/gui_logger_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ class GuiLoggerSink : public spdlog::sinks::base_sink<std::mutex>
spdlog::memory_buf_t formatted;
spdlog::sinks::base_sink<std::mutex>::formatter_->format(
msg, formatted);
const auto time = std::chrono::current_zone()
->to_local(std::chrono::system_clock::now());
const auto current_milli{
duration_cast<std::chrono::milliseconds>(time.time_since_epoch())
.count() % 1000};
const auto time_p = std::format("{:%X}.{:03} ", time, current_milli);
std::string formatted_message(msg.payload.begin(), msg.payload.end());
logs.push_back({msg.level, std::move(formatted_message)});
logs.push_back({msg.level, std::move(time_p + formatted_message)});
}
void flush_() override
{
Expand Down

0 comments on commit 2c66763

Please sign in to comment.