diff --git a/src/debug.cpp b/src/debug.cpp index 50e5b7e22..38bb52c16 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -258,5 +258,5 @@ void Logger::preinit(bool skip_repeated) } std::atomic Logger::last_msg{}; -bool Logger::skip_repeated = true; +std::atomic Logger::skip_repeated{true}; diff --git a/src/debug.h b/src/debug.h index 445ae6dc9..e342c09a4 100644 --- a/src/debug.h +++ b/src/debug.h @@ -92,6 +92,8 @@ bool set_log_level(const char *optarg, bool *logger_repeat_msgs); #include "compat/platform_time.h" #include "rang.hpp" +class keyboard_control; // friend + // Log, version 0.1: a simple logging class class Logger { @@ -145,12 +147,14 @@ private: int level; std::ostringstream oss; - static bool skip_repeated; + static std::atomic skip_repeated; struct last_message { std::string msg; int count{0}; }; static std::atomic last_msg; // leaks last message upon exit + + friend class keyboard_control; }; #define LOG(level) \ diff --git a/src/keyboard_control.cpp b/src/keyboard_control.cpp index 69691fd45..35bd550bc 100644 --- a/src/keyboard_control.cpp +++ b/src/keyboard_control.cpp @@ -121,7 +121,7 @@ keyboard_control::keyboard_control(struct module *parent) : m_should_exit(false), m_started(false), m_locked_against_changes(true), - guarded_keys { '*', '/', '9', '0', 'c', 'C', 'm', 'M', '>', '<', 'e', 's', 'S', 'v', 'V' } + guarded_keys { '*', '/', '9', '0', 'c', 'C', 'm', 'M', '>', '<', 'e', 's', 'S', 'v', 'V', 'r' } { m_start_time = time(NULL); @@ -540,6 +540,10 @@ void keyboard_control::run() cout << "Log level: " << log_level << "\n"; break; } + case 'r': + Logger::skip_repeated = !Logger::skip_repeated; + cout << "Skip repeated messages: " << std::boolalpha << Logger::skip_repeated << std::noboolalpha << "\n"; + break; case 's': if (saved_log_level == -1) { saved_log_level = log_level; @@ -672,6 +676,7 @@ void keyboard_control::usage() BOLD("\t M ") << "- mute/unmute sender" << G('M') << "\n" << BOLD("\t v ") << "- increase verbosity level" << G('v') << "\n" << BOLD("\t V ") << "- decrease verbosity level" << G('V') << "\n" << + BOLD("\t r ") << "- skip repeated messages (toggle) " << G('r') << "\n" << BOLD("\t e ") << "- record captured content (toggle)" << G('e') << "\n" << BOLD("\t h ") << "- show help" << G('h') << "\n" << BOLD("\t i ") << "- show various information" << G('i') << "\n" <<