mirror of
https://github.com/hyprwm/Hypr.git
synced 2025-02-16 16:22:06 +01:00
made logging cheaper
This commit is contained in:
parent
158260c0ec
commit
21eab55ffb
4 changed files with 10 additions and 10 deletions
|
@ -30,6 +30,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
const int BARRET = barMainThread();
|
const int BARRET = barMainThread();
|
||||||
Debug::log(BARRET == 0 ? LOG : ERR, "Bar exited with code " + std::to_string(BARRET) + "!");
|
Debug::log(BARRET == 0 ? LOG : ERR, "Bar exited with code " + std::to_string(BARRET) + "!");
|
||||||
|
g_pWindowManager->DebugOfstream.close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +74,8 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
xcb_disconnect(g_pWindowManager->DisplayConnection);
|
xcb_disconnect(g_pWindowManager->DisplayConnection);
|
||||||
|
|
||||||
|
g_pWindowManager->DebugOfstream.close();
|
||||||
|
|
||||||
if (const auto err = xcb_connection_has_error(g_pWindowManager->DisplayConnection); err != 0) {
|
if (const auto err = xcb_connection_has_error(g_pWindowManager->DisplayConnection); err != 0) {
|
||||||
Debug::log(CRIT, "Exiting because of error " + std::to_string(err));
|
Debug::log(CRIT, "Exiting because of error " + std::to_string(err));
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Debug.hpp"
|
#include "Debug.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include "../windowManager.hpp"
|
||||||
|
|
||||||
void Debug::log(LogLevel level, std::string msg) {
|
void Debug::log(LogLevel level, std::string msg) {
|
||||||
switch (level)
|
switch (level)
|
||||||
|
@ -26,14 +27,5 @@ void Debug::log(LogLevel level, std::string msg) {
|
||||||
printf((msg + "\n").c_str());
|
printf((msg + "\n").c_str());
|
||||||
|
|
||||||
// also log to a file
|
// also log to a file
|
||||||
const char* const ENVHOME = getenv("HOME");
|
g_pWindowManager->DebugOfstream << msg << "\n";
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
|
@ -30,6 +30,10 @@ void CWindowManager::createAndOpenAllPipes() {
|
||||||
system("cat \" \" > /tmp/hypr/hyprbarout");
|
system("cat \" \" > /tmp/hypr/hyprbarout");
|
||||||
system("cat \" \" > /tmp/hypr/hyprbarind");
|
system("cat \" \" > /tmp/hypr/hyprbarind");
|
||||||
system("cat \" \" > /tmp/hypr/hyprbaroutd");
|
system("cat \" \" > /tmp/hypr/hyprbaroutd");
|
||||||
|
|
||||||
|
// open the debug file
|
||||||
|
const std::string DEBUGPATH = "/tmp/hypr/hypr.log";
|
||||||
|
DebugOfstream.open(DEBUGPATH, std::ios::out | std::ios::app);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::updateRootCursor() {
|
void CWindowManager::updateRootCursor() {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
class CWindowManager {
|
class CWindowManager {
|
||||||
public:
|
public:
|
||||||
|
std::ofstream DebugOfstream;
|
||||||
xcb_connection_t* DisplayConnection = nullptr;
|
xcb_connection_t* DisplayConnection = nullptr;
|
||||||
xcb_ewmh_connection_t* EWMHConnection = nullptr; // Bar uses this
|
xcb_ewmh_connection_t* EWMHConnection = nullptr; // Bar uses this
|
||||||
xcb_screen_t* Screen = nullptr;
|
xcb_screen_t* Screen = nullptr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue