IPC and log changes, introduce signature

This commit is contained in:
vaxerski 2022-06-03 17:41:57 +02:00
parent 19b17b590c
commit 6f3b004199
8 changed files with 46 additions and 16 deletions

View file

@ -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);

View file

@ -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:

View file

@ -12,5 +12,8 @@ enum LogLevel {
};
namespace Debug {
void init();
void log(LogLevel level, const char* fmt, ...);
inline std::string logFile;
};