From 085261c2055a2f51f0fa86f2292952254f04e95e Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 21 Nov 2021 16:26:50 +0100 Subject: [PATCH] fixed an oopsie and added logging to file --- src/config/ConfigManager.cpp | 8 ++++++++ src/utilities/Debug.cpp | 13 +++++++++++++ src/windowManager.cpp | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 2f3ae33..e3a0522 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -17,6 +17,14 @@ void ConfigManager::init() { configValues["max_fps"].intValue = 60; ConfigManager::loadConfigLoadVars(); + + // Clear logs + std::ofstream logs; + const char* const ENVHOME = getenv("HOME"); + const std::string DEBUGPATH = ENVHOME + (std::string) "/.hypr.log"; + logs.open(DEBUGPATH, std::ios::out | std::ios::trunc); + logs << " "; + logs.close(); } void handleBind(const std::string& command, const std::string& value) { diff --git a/src/utilities/Debug.cpp b/src/utilities/Debug.cpp index dfb7b23..3074dea 100644 --- a/src/utilities/Debug.cpp +++ b/src/utilities/Debug.cpp @@ -1,4 +1,5 @@ #include "Debug.hpp" +#include void Debug::log(LogLevel level, std::string msg) { switch (level) @@ -23,4 +24,16 @@ void Debug::log(LogLevel level, std::string msg) { break; } printf((msg + "\n").c_str()); + + // also log to a file + const char* const ENVHOME = getenv("HOME"); + + const std::string DEBUGPATH = ENVHOME + (std::string) "/.hypr.log"; + std::ofstream ofs; + + ofs.open(DEBUGPATH, std::ios::out | std::ios::app); + + ofs << msg << "\n"; + + ofs.close(); } \ No newline at end of file diff --git a/src/windowManager.cpp b/src/windowManager.cpp index a734239..56b5237 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -91,7 +91,7 @@ bool CWindowManager::handleEvent() { Debug::log(LOG, "Event dispatched MAP"); break; case XCB_BUTTON_PRESS: - Events::eventButtonPress(ev); + Events::eventKeyPress(ev); Debug::log(LOG, "Event dispatched BUTTON_PRESS"); break; case XCB_EXPOSE: @@ -99,7 +99,7 @@ bool CWindowManager::handleEvent() { Debug::log(LOG, "Event dispatched EXPOSE"); break; case XCB_KEY_PRESS: - Events::eventKeyPress(ev); + Events::eventButtonPress(ev); Debug::log(LOG, "Event dispatched KEY_PRESS"); break;