summaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-06-03 17:41:57 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-06-03 17:41:57 +0200
commit6f3b004199a6b1bb0a8f5431d677ab926bdf19f3 (patch)
tree227dec00bfbcefa60cf0ebe7329508f439237c62 /src/debug
parent19b17b590c8a2dc19e79542796c7b1b8e65301de (diff)
IPC and log changes, introduce signature
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/HyprCtl.cpp8
-rw-r--r--src/debug/Log.cpp10
-rw-r--r--src/debug/Log.hpp3
3 files changed, 15 insertions, 6 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index c890dbb2..a8030992 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -266,11 +266,11 @@ void HyprCtl::startHyprCtlSocket() {
return;
}
- unlink("/tmp/hypr/.socket.sock");
-
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
- strcpy(SERVERADDRESS.sun_path, "/tmp/hypr/.socket.sock");
+ std::string socketPath = "/tmp/hypr/" + g_pCompositor->m_szInstanceSignature + "/.socket.sock";
+
+ strcpy(SERVERADDRESS.sun_path, socketPath.c_str());
bind(SOCKET, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS));
@@ -282,7 +282,7 @@ void HyprCtl::startHyprCtlSocket() {
char readBuffer[1024] = {0};
- Debug::log(LOG, "Hypr socket started.");
+ Debug::log(LOG, "Hypr socket started at %s", socketPath.c_str());
while(1) {
const auto ACCEPTEDCONNECTION = accept(SOCKET, (sockaddr*)&clientAddress, &clientSize);
diff --git a/src/debug/Log.cpp b/src/debug/Log.cpp
index 3a008758..b3d13583 100644
--- a/src/debug/Log.cpp
+++ b/src/debug/Log.cpp
@@ -4,12 +4,18 @@
#include <fstream>
#include <iostream>
+void Debug::init() {
+ if (ISDEBUG)
+ logFile = "/tmp/hypr/hyprlandd-" + std::to_string(time(NULL)) + ".log";
+ else
+ logFile = "/tmp/hypr/hyprland-" + std::to_string(time(NULL)) + ".log";
+}
+
void Debug::log(LogLevel level, const char* fmt, ...) {
// log to a file
- const std::string DEBUGPATH = ISDEBUG ? "/tmp/hypr/hyprlandd.log" : "/tmp/hypr/hyprland.log";
std::ofstream ofs;
- ofs.open(DEBUGPATH, std::ios::out | std::ios::app);
+ ofs.open(logFile, std::ios::out | std::ios::app);
switch (level) {
case LOG:
diff --git a/src/debug/Log.hpp b/src/debug/Log.hpp
index 7dca950f..d5aa6958 100644
--- a/src/debug/Log.hpp
+++ b/src/debug/Log.hpp
@@ -12,5 +12,8 @@ enum LogLevel {
};
namespace Debug {
+ void init();
void log(LogLevel level, const char* fmt, ...);
+
+ inline std::string logFile;
}; \ No newline at end of file