Add debug button to request a log entry from the logcat thread
This commit is contained in:
parent
be07a6b3aa
commit
d9c7184b0e
|
@ -109,7 +109,7 @@ static inline void main_window(bool latest_log_entries_read, bool* show_settings
|
|||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
static inline void debug_window() {
|
||||
static inline void debug_window(LogcatThread& logcat_thread) {
|
||||
static bool show_demo_window = false;
|
||||
static size_t add_log_entry_presses = 1;
|
||||
static bool log_entry_every_second = false;
|
||||
|
@ -138,6 +138,9 @@ static inline void debug_window() {
|
|||
if (ImGui::Button("Add Log Entry with Newlines")) {
|
||||
log("The following should have five spaces: \"\n\n\n\n\n\"");
|
||||
}
|
||||
if (ImGui::Button("Request log entry from Logcat thread")) {
|
||||
logcat_thread.debug_log_request.test_and_set();
|
||||
}
|
||||
|
||||
if (log_entry_every_second) {
|
||||
log_entry_every_second_delta += ImGui::GetIO().DeltaTime;
|
||||
|
@ -159,7 +162,7 @@ void event_loop(ImFont* monospace_font, Config& config, float* config_write_time
|
|||
check_for_logcat_items(logcat_thread);
|
||||
|
||||
#ifndef NDEBUG
|
||||
debug_window();
|
||||
debug_window(logcat_thread);
|
||||
#endif
|
||||
|
||||
if (show_settings_window) {
|
||||
|
|
|
@ -106,6 +106,12 @@ void LogcatThread::_run(std::stop_token stoken) {
|
|||
|
||||
while (!stoken.stop_requested()) {
|
||||
printf("(boop)\n");
|
||||
#ifndef NDEBUG
|
||||
if (this->debug_log_request.test()) {
|
||||
this->atomic_ring_buffer.put_and_increment_write(format_log("A log entry from the logcat thread :D"));
|
||||
this->debug_log_request.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
int ready_fds = epoll_wait(this->_epoll_fd, events, EPOLL_MAX_EVENTS, 1000);
|
||||
if (ready_fds == -1) {
|
||||
|
|
|
@ -19,6 +19,10 @@ public:
|
|||
|
||||
AtomicRingBuffer<LogcatThreadItem> atomic_ring_buffer;
|
||||
|
||||
#ifndef NDEBUG
|
||||
std::atomic_flag debug_log_request;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void _run(std::stop_token stoken);
|
||||
|
||||
|
|
Loading…
Reference in New Issue