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/logging/context.h b/aos/logging/context.h
index 25a7233..721b04b 100644
--- a/aos/logging/context.h
+++ b/aos/logging/context.h
@@ -8,6 +8,7 @@
#include <climits>
#include <cstddef>
#include <memory>
+#include <string_view>
#include "aos/logging/sizes.h"
@@ -50,14 +51,19 @@
std::shared_ptr<LogImplementation> implementation;
// A name representing this task/(process and thread).
- char name[LOG_MESSAGE_NAME_LEN];
- size_t name_size;
+ std::string_view MyName();
+ // Clears the cached name so MyName re-checks the thread's actual name.
+ void ClearName();
// What to assign LogMessage::source to in this task/thread.
pid_t source;
// The sequence value to send out with the next message.
uint16_t sequence;
+
+ private:
+ size_t name_size;
+ char name[LOG_MESSAGE_NAME_LEN];
};
} // namespace internal