Use the event loop name instead of thread name for AOS_LOG
This kills 2 birds with 1 stone.
1) A simulated event loop should print out the name of each event
loop, not the program name.
2) prctl(PR_GET_NAME, thread_name_array) can require higher privileges
sometimes, and is un-necesary for simulations. See 1)
Change-Id: I48731b1cabe34ec66a97f27ee720ba3081da4e94
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/events/simulated_event_loop.cc b/aos/events/simulated_event_loop.cc
index 121e164..9e12481 100644
--- a/aos/events/simulated_event_loop.cc
+++ b/aos/events/simulated_event_loop.cc
@@ -609,6 +609,10 @@
void OnRun(::std::function<void()> on_run) override {
CHECK(!is_running()) << ": Cannot register OnRun callback while running.";
scheduler_->ScheduleOnRun([this, on_run = std::move(on_run)]() {
+ logging::ScopedLogRestorer prev_logger;
+ if (log_impl_) {
+ prev_logger.Swap(log_impl_);
+ }
ScopedMarkRealtimeRestorer rt(priority() > 0);
SetTimerContext(monotonic_now());
on_run();
@@ -638,7 +642,8 @@
void Setup() {
MaybeScheduleTimingReports();
if (!skip_logger_) {
- log_sender_.Initialize(MakeSender<logging::LogMessageFbs>("/aos"));
+ log_sender_.Initialize(&name_,
+ MakeSender<logging::LogMessageFbs>("/aos"));
log_impl_ = log_sender_.implementation();
}
}