From 6175ecd4c4ba817c4620f66a75e1e11da7c7a8ca Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Thu, 18 Dec 2025 17:23:24 +0000 Subject: debug: move to hyprutils' logger (#12673) --- src/helpers/MiscFunctions.cpp | 44 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'src/helpers/MiscFunctions.cpp') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 25b179e9..79504b31 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef HAS_EXECINFO #include #endif @@ -103,7 +104,7 @@ std::optional getPlusMinusKeywordResult(std::string source, float relativ try { return relative + stof(source); } catch (...) { - Debug::log(ERR, "Invalid arg \"{}\" in getPlusMinusKeywordResult!", source); + Log::logger->log(Log::ERR, "Invalid arg \"{}\" in getPlusMinusKeywordResult!", source); return {}; } } @@ -148,7 +149,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) { const bool same_mon = in.substr(5).contains("m"); const bool next = in.substr(5).contains("n"); if ((same_mon || next) && !Desktop::focusState()->monitor()) { - Debug::log(ERR, "Empty monitor workspace on monitor null!"); + Log::logger->log(Log::ERR, "Empty monitor workspace on monitor null!"); return {WORKSPACE_INVALID}; } @@ -186,14 +187,14 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) { const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PREVWORKSPACEIDNAME.id); if (!PLASTWORKSPACE) { - Debug::log(LOG, "previous workspace {} doesn't exist yet", PREVWORKSPACEIDNAME.id); + Log::logger->log(Log::DEBUG, "previous workspace {} doesn't exist yet", PREVWORKSPACEIDNAME.id); return {PREVWORKSPACEIDNAME.id, PREVWORKSPACEIDNAME.name}; } return {PLASTWORKSPACE->m_id, PLASTWORKSPACE->m_name}; } else if (in == "next") { if (!Desktop::focusState()->monitor() || !Desktop::focusState()->monitor()->m_activeWorkspace) { - Debug::log(ERR, "no active monitor or workspace for 'next'"); + Log::logger->log(Log::ERR, "no active monitor or workspace for 'next'"); return {WORKSPACE_INVALID}; } @@ -211,7 +212,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) { if (in[0] == 'r' && (in[1] == '-' || in[1] == '+' || in[1] == '~') && isNumber(in.substr(2))) { bool absolute = in[1] == '~'; if (!Desktop::focusState()->monitor()) { - Debug::log(ERR, "Relative monitor workspace on monitor null!"); + Log::logger->log(Log::ERR, "Relative monitor workspace on monitor null!"); return {WORKSPACE_INVALID}; } @@ -373,7 +374,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) { bool absolute = in[1] == '~'; if (!Desktop::focusState()->monitor()) { - Debug::log(ERR, "Relative monitor workspace on monitor null!"); + Log::logger->log(Log::ERR, "Relative monitor workspace on monitor null!"); return {WORKSPACE_INVALID}; } @@ -445,7 +446,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) { result.id = std::max(sc(PLUSMINUSRESULT.value()), 1); } else { - Debug::log(ERR, "Relative workspace on no mon!"); + Log::logger->log(Log::ERR, "Relative workspace on no mon!"); return {WORKSPACE_INVALID}; } } else if (isNumber(in)) @@ -524,12 +525,12 @@ void logSystemInfo() { uname(&unameInfo); - Debug::log(LOG, "System name: {}", std::string{unameInfo.sysname}); - Debug::log(LOG, "Node name: {}", std::string{unameInfo.nodename}); - Debug::log(LOG, "Release: {}", std::string{unameInfo.release}); - Debug::log(LOG, "Version: {}", std::string{unameInfo.version}); + Log::logger->log(Log::DEBUG, "System name: {}", std::string{unameInfo.sysname}); + Log::logger->log(Log::DEBUG, "Node name: {}", std::string{unameInfo.nodename}); + Log::logger->log(Log::DEBUG, "Release: {}", std::string{unameInfo.release}); + Log::logger->log(Log::DEBUG, "Version: {}", std::string{unameInfo.version}); - Debug::log(NONE, "\n"); + Log::logger->log(Log::DEBUG, "\n"); #if defined(__DragonFly__) || defined(__FreeBSD__) const std::string GPUINFO = execAndGet("pciconf -lv | grep -F -A4 vga"); @@ -555,16 +556,16 @@ void logSystemInfo() { #else const std::string GPUINFO = execAndGet("lspci -vnn | grep -E '(VGA|Display|3D)'"); #endif - Debug::log(LOG, "GPU information:\n{}\n", GPUINFO); + Log::logger->log(Log::DEBUG, "GPU information:\n{}\n", GPUINFO); if (GPUINFO.contains("NVIDIA")) { - Debug::log(WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n"); + Log::logger->log(Log::WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n"); } // log etc - Debug::log(LOG, "os-release:"); + Log::logger->log(Log::DEBUG, "os-release:"); - Debug::log(NONE, "{}", NFsUtils::readFileAsString("/etc/os-release").value_or("error")); + Log::logger->log(Log::DEBUG, "{}", NFsUtils::readFileAsString("/etc/os-release").value_or("error")); } int64_t getPPIDof(int64_t pid) { @@ -767,17 +768,10 @@ std::vector getBacktrace() { } void throwError(const std::string& err) { - Debug::log(CRIT, "Critical error thrown: {}", err); + Log::logger->log(Log::CRIT, "Critical error thrown: {}", err); throw std::runtime_error(err); } -bool envEnabled(const std::string& env) { - const auto ENV = getenv(env.c_str()); - if (!ENV) - return false; - return std::string(ENV) == "1"; -} - std::pair openExclusiveShm() { // Only absolute paths can be shared across different shm_open() calls std::string name = "/" + g_pTokenManager->getRandomUUID(); @@ -872,7 +866,7 @@ bool isNvidiaDriverVersionAtLeast(int threshold) { if (firstDot != std::string::npos) driverMajor = std::stoi(driverInfo.substr(0, firstDot)); - Debug::log(LOG, "Parsed NVIDIA major version: {}", driverMajor); + Log::logger->log(Log::DEBUG, "Parsed NVIDIA major version: {}", driverMajor); } catch (std::exception& e) { driverMajor = 0; // Default to 0 if parsing fails -- cgit v1.2.3