From a6a53eb98a7062fe4291cf1c96b81010c5ab8fb8 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 3 Feb 2023 15:15:54 +0700 Subject: [PATCH] Actually use default logcat command --- config.h | 2 ++ logcat_thread.cpp | 7 ++++++- windows/settings.cpp | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 5555ff4..fd19673 100644 --- a/config.h +++ b/config.h @@ -4,6 +4,8 @@ #include #include "filters.h" +const constexpr char* default_logcat_command = "adb logcat -Dv 'threadtime epoch UTC uid'"; + struct Config { std::string logcat_command; float normal_font_size = 13.0f; diff --git a/logcat_thread.cpp b/logcat_thread.cpp index 5e9dbc3..4f64c6d 100644 --- a/logcat_thread.cpp +++ b/logcat_thread.cpp @@ -8,6 +8,7 @@ #include "log.h" #include "misc.h" +#include "config.h" #include "logcat_thread.h" #include "logcat_entry.h" @@ -320,6 +321,10 @@ bool LogcatThread::_handle_start_request() { } }; + std::string logcat_command = !this->_logcat_command->empty() + ? *this->_logcat_command + : default_logcat_command; + this->_logcat_pid = fork(); if (this->_logcat_pid == -1) { try { @@ -337,7 +342,7 @@ bool LogcatThread::_handle_start_request() { close_or_warn(this->_stderr_write_fd); close_or_warn(this->_stdout_read_fd); close_or_warn(this->_stderr_read_fd); - execlp("sh", "sh", "-c", this->_logcat_command->c_str(), nullptr); + execlp("sh", "sh", "-c", logcat_command.c_str(), nullptr); try { throw_system_error("execlp()"); } catch (const std::exception& e) { diff --git a/windows/settings.cpp b/windows/settings.cpp index 199d2e0..4ade920 100644 --- a/windows/settings.cpp +++ b/windows/settings.cpp @@ -18,7 +18,7 @@ void settings_window(Config& active_config, Config& inactive_config, bool* p_ope return; } ImGui::TextUnformatted("Logcat command only takes effect when logcat is not running"); - ImGui::InputTextWithHint("Logcat command", "adb logcat -Dv 'threadtime UTC epoch usec uid'", &inactive_config.logcat_command); + ImGui::InputTextWithHint("Logcat command", default_logcat_command, &inactive_config.logcat_command); ImGui::Text("Font sizes only take effect when LogMeow is restarted"); #ifdef USE_FONTCONFIG