From 1ed394e3ef299c6db2182723984c0e1ac8498215 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 24 Jan 2026 21:24:23 -0500 Subject: [PATCH] refactor: remove DEBUG3 and move DEBUG3 messages to DEBUG2 --- src/lib/base/Log.cpp | 4 ++-- src/lib/base/Log.h | 2 -- src/lib/base/LogLevel.h | 3 +-- src/lib/deskflow/KeyMap.cpp | 2 +- src/lib/platform/MSWindowsScreen.cpp | 8 ++++---- src/lib/platform/MSWindowsWatchdog.cpp | 14 +++++++------- src/lib/platform/OSXScreen.mm | 2 +- src/lib/platform/XWindowsScreen.cpp | 2 +- src/lib/server/Server.cpp | 2 +- src/unittests/base/LogTests.cpp | 4 ++-- src/unittests/legacytests/legacytests/main.cpp | 2 +- 11 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/lib/base/Log.cpp b/src/lib/base/Log.cpp index bba61cce0..c83b7578d 100644 --- a/src/lib/base/Log.cpp +++ b/src/lib/base/Log.cpp @@ -24,10 +24,10 @@ const int kPriorityPrefixLength = 3; // names of priorities -static const char *g_priority[] = {"FATAL", "ERROR", "WARNING", "NOTE", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3"}; +static const char *g_priority[] = {"FATAL", "ERROR", "WARNING", "NOTE", "INFO", "DEBUG", "DEBUG1", "DEBUG2"}; // number of priorities -static const int g_numPriority = 9; +static const int g_numPriority = 8; // if NDEBUG (not debug) is not specified, i.e. you're building in debug, // then set default log level to DEBUG, otherwise the max level is INFO. diff --git a/src/lib/base/Log.h b/src/lib/base/Log.h index 52bf866d6..eb9a53e33 100644 --- a/src/lib/base/Log.h +++ b/src/lib/base/Log.h @@ -209,7 +209,6 @@ otherwise it expands to a call that doesn't. #define CLOG_DEBUG CLOG_TRACE "%z\065" #define CLOG_DEBUG1 CLOG_TRACE "%z\066" #define CLOG_DEBUG2 CLOG_TRACE "%z\067" -#define CLOG_DEBUG3 CLOG_TRACE "%z\070" #define LOG_IPC(...) LOG((CLOG_IPC __VA_ARGS__)) #define LOG_PRINT(...) LOG((CLOG_PRINT __VA_ARGS__)) @@ -221,4 +220,3 @@ otherwise it expands to a call that doesn't. #define LOG_DEBUG(...) LOG((CLOG_DEBUG __VA_ARGS__)) #define LOG_DEBUG1(...) LOG((CLOG_DEBUG1 __VA_ARGS__)) #define LOG_DEBUG2(...) LOG((CLOG_DEBUG2 __VA_ARGS__)) -#define LOG_DEBUG3(...) LOG((CLOG_DEBUG3 __VA_ARGS__)) diff --git a/src/lib/base/LogLevel.h b/src/lib/base/LogLevel.h index 404b70a0e..afaa100f6 100644 --- a/src/lib/base/LogLevel.h +++ b/src/lib/base/LogLevel.h @@ -22,6 +22,5 @@ enum class LogLevel Info, //!< For informational messages Debug, //!< For important debugging messages Debug1, //!< For verbosity +1 debugging messages - Debug2, //!< For verbosity +2 debugging messages - Debug3 //!< For verbosity +3 debugging messages + Debug2 //!< For verbosity +2 debugging messages }; diff --git a/src/lib/deskflow/KeyMap.cpp b/src/lib/deskflow/KeyMap.cpp index d59d06693..967e2bccc 100644 --- a/src/lib/deskflow/KeyMap.cpp +++ b/src/lib/deskflow/KeyMap.cpp @@ -88,7 +88,7 @@ void KeyMap::addKeyEntry(const KeyItem &item) // add item list entries.push_back(items); LOG( - (CLOG_DEBUG3 "add key: %04x %d %03x %04x (%04x %04x %04x)%s", newItem.m_id, newItem.m_group, newItem.m_button, + (CLOG_DEBUG2 "add key: %04x %d %03x %04x (%04x %04x %04x)%s", newItem.m_id, newItem.m_group, newItem.m_button, newItem.m_client, newItem.m_required, newItem.m_sensitive, newItem.m_generates, newItem.m_dead ? " dead" : "") ); } diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp index 01fbc32e6..57afe583d 100644 --- a/src/lib/platform/MSWindowsScreen.cpp +++ b/src/lib/platform/MSWindowsScreen.cpp @@ -535,7 +535,7 @@ void MSWindowsScreen::saveMousePosition(int32_t x, int32_t y) m_xCursor = x; m_yCursor = y; - LOG_DEBUG3("saved mouse position for next delta: %+d,%+d", x, y); + LOG_DEBUG2("saved mouse position for next delta: %+d,%+d", x, y); } uint32_t MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) @@ -883,7 +883,7 @@ bool MSWindowsScreen::onPreDispatch(HWND hwnd, UINT message, WPARAM wParam, LPAR bool MSWindowsScreen::onPreDispatchPrimary(HWND, UINT message, WPARAM wParam, LPARAM lParam) { - LOG_DEBUG3("handling pre-dispatch primary"); + LOG_DEBUG2("handling pre-dispatch primary"); // handle event switch (message) { @@ -1226,7 +1226,7 @@ bool MSWindowsScreen::onMouseMove(int32_t mx, int32_t my) int32_t x = mx - m_xCursor; int32_t y = my - m_yCursor; - LOG_DEBUG3("mouse move - motion delta: %+d=(%+d - %+d),%+d=(%+d - %+d)", x, mx, m_xCursor, y, my, m_yCursor); + LOG_DEBUG2("mouse move - motion delta: %+d=(%+d - %+d),%+d=(%+d - %+d)", x, mx, m_xCursor, y, my, m_yCursor); // ignore if the mouse didn't move or if message posted prior // to last mark change. @@ -1245,7 +1245,7 @@ bool MSWindowsScreen::onMouseMove(int32_t mx, int32_t my) // center on the server screen. if we don't do this, then the mouse // will always try to return to the original entry point on the // secondary screen. - LOG_DEBUG3("centering cursor on motion: %+d,%+d", m_xCenter, m_yCenter); + LOG_DEBUG2("centering cursor on motion: %+d,%+d", m_xCenter, m_yCenter); warpCursorNoFlush(m_xCenter, m_yCenter); // examine the motion. if it's about the distance diff --git a/src/lib/platform/MSWindowsWatchdog.cpp b/src/lib/platform/MSWindowsWatchdog.cpp index baa578e69..b494abd68 100644 --- a/src/lib/platform/MSWindowsWatchdog.cpp +++ b/src/lib/platform/MSWindowsWatchdog.cpp @@ -159,7 +159,7 @@ void MSWindowsWatchdog::mainLoop(const void *) LOG_DEBUG("starting watchdog main loop"); while (m_running) { - LOG_DEBUG3("locking process state mutex in watchdog main loop"); + LOG_DEBUG2("locking process state mutex in watchdog main loop"); std::unique_lock lock(m_processStateMutex); if (m_processState == Running && !m_command.empty() && !m_foreground && m_session.hasChanged()) { @@ -170,11 +170,11 @@ void MSWindowsWatchdog::mainLoop(const void *) switch (m_processState) { case Idle: - LOG_DEBUG3("watchdog process state idle"); + LOG_DEBUG2("watchdog process state idle"); break; case StartScheduled: { - LOG_DEBUG3("watchdog process start scheduled"); + LOG_DEBUG2("watchdog process start scheduled"); if (m_nextStartTime.has_value() && m_nextStartTime.value() <= Arch::time()) { LOG_DEBUG("start time reached, queueing process start"); m_processState = StartPending; @@ -195,7 +195,7 @@ void MSWindowsWatchdog::mainLoop(const void *) } break; case Running: { - LOG_DEBUG3("watchdog process in running state"); + LOG_DEBUG2("watchdog process in running state"); if (!isProcessRunning()) { LOG_WARN("detected application not running, pid=%d", m_process->info().dwProcessId); m_processState = StartPending; @@ -215,11 +215,11 @@ void MSWindowsWatchdog::mainLoop(const void *) } break; } - LOG_DEBUG3("unlocking process state mutex in watchdog main loop"); + LOG_DEBUG2("unlocking process state mutex in watchdog main loop"); lock.unlock(); // Sleep for only 100ms rather than 1 second so that the service can shut down faster. - LOG_DEBUG3("watchdog main loop sleeping"); + LOG_DEBUG2("watchdog main loop sleeping"); Arch::sleep(0.1); } @@ -499,7 +499,7 @@ void MSWindowsWatchdog::initSasFunc() void MSWindowsWatchdog::sasLoop(const void *) // NOSONAR - Thread entry point signature { - LOG_DEBUG3("watchdog creating sas event"); + LOG_DEBUG2("watchdog creating sas event"); if (m_sendSasFunc == nullptr) { throw std::runtime_error("SendSAS function not initialized"); diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index 19afc2504..a4c3c7c03 100644 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -1681,7 +1681,7 @@ CGEventRef OSXScreen::handleCGInputEvent(CGEventTapProxy proxy, CGEventType type break; } - LOG_DEBUG3("unknown quartz event type: 0x%02x", type); + LOG_DEBUG2("unknown quartz event type: 0x%02x", type); } if (screen->m_isOnScreen) { diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp index c57ebf847..a52a59a16 100644 --- a/src/lib/platform/XWindowsScreen.cpp +++ b/src/lib/platform/XWindowsScreen.cpp @@ -846,7 +846,7 @@ Display *XWindowsScreen::openDisplay(const char *displayName) } // open the display - LOG_DEBUG3("calling XOpenDisplay(\"%s\")", displayName); + LOG_DEBUG2("calling XOpenDisplay(\"%s\")", displayName); Display *display = XOpenDisplay(displayName); if (display == nullptr) { throw ScreenUnavailableException(60.0); diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 239964864..0327de636 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -1609,7 +1609,7 @@ void Server::onMouseUp(ButtonID id) bool Server::onMouseMovePrimary(int32_t x, int32_t y) { - LOG_DEBUG3("onMouseMovePrimary %d,%d", x, y); + LOG_DEBUG2("onMouseMovePrimary %d,%d", x, y); // mouse move on primary (server's) screen if (m_active != m_primaryClient) { diff --git a/src/unittests/base/LogTests.cpp b/src/unittests/base/LogTests.cpp index 9a2b5071a..24070bd13 100644 --- a/src/unittests/base/LogTests.cpp +++ b/src/unittests/base/LogTests.cpp @@ -24,7 +24,7 @@ QString sanitizeBuffer(const std::stringstream &in) void LogTests::initTestCase() { - m_log.setFilter(LogLevel::Debug2); + m_log.setFilter(LogLevel::Debug1); } void LogTests::printWithErrorValidOutput() @@ -85,7 +85,7 @@ void LogTests::printLevelToHigh() std::stringstream buffer; std::streambuf *old = std::cout.rdbuf(buffer.rdbuf()); - m_log.print(CLOG_DEBUG3 "test message"); + m_log.print(CLOG_DEBUG2 "test message"); auto string = sanitizeBuffer(buffer); std::cout.rdbuf(old); diff --git a/src/unittests/legacytests/legacytests/main.cpp b/src/unittests/legacytests/legacytests/main.cpp index 8114e8dbd..e718bd638 100644 --- a/src/unittests/legacytests/legacytests/main.cpp +++ b/src/unittests/legacytests/legacytests/main.cpp @@ -32,7 +32,7 @@ int main(int argc, char **argv) arch.init(); Log log; - log.setFilter(LogLevel::Debug3); + log.setFilter(LogLevel::Debug2); ::testing::GTEST_FLAG(throw_on_failure) = true; testing::InitGoogleTest(&argc, argv);