From 868e0f48d023714a205acf071594983d22d1478c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 1 Jul 2022 15:57:56 +0200 Subject: [PATCH] added debug:disable_logs --- src/config/ConfigManager.cpp | 3 +++ src/debug/Log.cpp | 3 +++ src/debug/Log.hpp | 1 + 3 files changed, 7 insertions(+) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 26503f7e..f313b155 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -15,6 +15,8 @@ CConfigManager::CConfigManager() { static const char* const ENVHOME = getenv("HOME"); const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf"); configPaths.emplace_back(CONFIGPATH); + + Debug::disableLogs = &configValues["debug:disable_logs"].intValue; } void CConfigManager::setDefaultVars() { @@ -39,6 +41,7 @@ void CConfigManager::setDefaultVars() { configValues["debug:log_damage"].intValue = 0; configValues["debug:overlay"].intValue = 0; configValues["debug:damage_blink"].intValue = 0; + configValues["debug:disable_logs"].intValue = 0; configValues["decoration:rounding"].intValue = 1; configValues["decoration:blur"].intValue = 1; diff --git a/src/debug/Log.cpp b/src/debug/Log.cpp index a864f0d2..2fa4a127 100644 --- a/src/debug/Log.cpp +++ b/src/debug/Log.cpp @@ -14,6 +14,9 @@ void Debug::init(std::string IS) { void Debug::log(LogLevel level, const char* fmt, ...) { + if (disableLogs && *disableLogs) + return; + // log to a file std::ofstream ofs; ofs.open(logFile, std::ios::out | std::ios::app); diff --git a/src/debug/Log.hpp b/src/debug/Log.hpp index 814da421..bde9b820 100644 --- a/src/debug/Log.hpp +++ b/src/debug/Log.hpp @@ -17,4 +17,5 @@ namespace Debug { void log(LogLevel level, const char* fmt, ...); inline std::string logFile; + inline int64_t* disableLogs = nullptr; }; \ No newline at end of file