summaryrefslogtreecommitdiff
path: root/src/xwayland/Server.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-12-18 17:23:24 +0000
committerGitHub <noreply@github.com>2025-12-18 17:23:24 +0000
commit6175ecd4c4ba817c4620f66a75e1e11da7c7a8ca (patch)
treecf73852f1fc08b1dcee5a3a7380f914aaad9c50a /src/xwayland/Server.cpp
parentf88deb928a0f7dc02f427473f8c29e8f2bed14a3 (diff)
debug: move to hyprutils' logger (#12673)
Diffstat (limited to 'src/xwayland/Server.cpp')
-rw-r--r--src/xwayland/Server.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/xwayland/Server.cpp b/src/xwayland/Server.cpp
index 6750db10..1ece7454 100644
--- a/src/xwayland/Server.cpp
+++ b/src/xwayland/Server.cpp
@@ -21,7 +21,7 @@
#include "Server.hpp"
#include "XWayland.hpp"
#include "config/ConfigValue.hpp"
-#include "debug/Log.hpp"
+#include "debug/log/Logger.hpp"
#include "../defines.hpp"
#include "../Compositor.hpp"
#include "../managers/CursorManager.hpp"
@@ -41,12 +41,12 @@ static CFileDescriptor createSocket(struct sockaddr_un* addr, size_t pathSize) {
socklen_t size = offsetof(struct sockaddr_un, sun_path) + pathSize + 1;
CFileDescriptor fd{socket(AF_UNIX, SOCK_STREAM, 0)};
if (!fd.isValid()) {
- Debug::log(ERR, "Failed to create socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
+ Log::logger->log(Log::ERR, "Failed to create socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
return {};
}
if (!fd.setFlags(fd.getFlags() | FD_CLOEXEC)) {
- Debug::log(ERR, "Failed to set flags for socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
+ Log::logger->log(Log::ERR, "Failed to set flags for socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
return {};
}
@@ -54,7 +54,7 @@ static CFileDescriptor createSocket(struct sockaddr_un* addr, size_t pathSize) {
unlink(addr->sun_path);
if (bind(fd.get(), rc<struct sockaddr*>(addr), size) < 0) {
- Debug::log(ERR, "Failed to bind socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
+ Log::logger->log(Log::ERR, "Failed to bind socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
if (isRegularSocket)
unlink(addr->sun_path);
return {};
@@ -66,11 +66,11 @@ static CFileDescriptor createSocket(struct sockaddr_un* addr, size_t pathSize) {
if (isRegularSocket && chmod(addr->sun_path, 0666) < 0) {
// We are only extending the default permissions,
// and I don't see the reason to make a full stop in case of a failed operation.
- Debug::log(ERR, "Failed to set permission mode for socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
+ Log::logger->log(Log::ERR, "Failed to set permission mode for socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
}
if (listen(fd.get(), SOCKET_BACKLOG) < 0) {
- Debug::log(ERR, "Failed to listen to socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
+ Log::logger->log(Log::ERR, "Failed to listen to socket {}{}", dbgSocketPathPrefix, dbgSocketPathRem);
if (isRegularSocket)
unlink(addr->sun_path);
return {};
@@ -83,23 +83,23 @@ static bool checkPermissionsForSocketDir() {
struct stat buf;
if (lstat("/tmp/.X11-unix", &buf)) {
- Debug::log(ERR, "Failed to stat X11 socket dir");
+ Log::logger->log(Log::ERR, "Failed to stat X11 socket dir");
return false;
}
if (!(buf.st_mode & S_IFDIR)) {
- Debug::log(ERR, "X11 socket dir is not a directory");
+ Log::logger->log(Log::ERR, "X11 socket dir is not a directory");
return false;
}
if ((buf.st_uid != 0) && (buf.st_uid != getuid())) {
- Debug::log(ERR, "X11 socket dir is not owned by root or current user");
+ Log::logger->log(Log::ERR, "X11 socket dir is not owned by root or current user");
return false;
}
if (!(buf.st_mode & S_ISVTX)) {
if ((buf.st_mode & (S_IWGRP | S_IWOTH))) {
- Debug::log(ERR, "X11 socket dir is writable by others");
+ Log::logger->log(Log::ERR, "X11 socket dir is writable by others");
return false;
}
}
@@ -112,7 +112,7 @@ static bool ensureSocketDirExists() {
if (errno == EEXIST)
return checkPermissionsForSocketDir();
else {
- Debug::log(ERR, "XWayland: Couldn't create socket dir");
+ Log::logger->log(Log::ERR, "XWayland: Couldn't create socket dir");
return false;
}
}
@@ -149,7 +149,7 @@ static bool openSockets(std::array<CFileDescriptor, 2>& sockets, int display) {
}
#else
if (*CREATEABSTRACTSOCKET) {
- Debug::log(WARN, "The abstract XWayland Unix domain socket might be used only on Linux systems. A regular one'll be created instead.");
+ Log::logger->log(Log::WARN, "The abstract XWayland Unix domain socket might be used only on Linux systems. A regular one'll be created instead.");
}
path = getSocketPath(display, false);
strncpy(addr.sun_path, path.c_str(), path.length() + 1);
@@ -173,7 +173,7 @@ static bool openSockets(std::array<CFileDescriptor, 2>& sockets, int display) {
static void startServer(void* data) {
if (!g_pXWayland->m_server->start())
- Debug::log(ERR, "The XWayland server could not start! XWayland will not work...");
+ Log::logger->log(Log::ERR, "The XWayland server could not start! XWayland will not work...");
}
static int xwaylandReady(int fd, uint32_t mask, void* data) {
@@ -183,7 +183,7 @@ static int xwaylandReady(int fd, uint32_t mask, void* data) {
static bool safeRemove(const std::string& path) {
try {
return std::filesystem::remove(path);
- } catch (const std::exception& e) { Debug::log(ERR, "[XWayland] Failed to remove {}", path); }
+ } catch (const std::exception& e) { Log::logger->log(Log::ERR, "[XWayland] Failed to remove {}", path); }
return false;
}
@@ -232,11 +232,11 @@ bool CXWaylandServer::tryOpenSockets() {
}
if (m_display < 0) {
- Debug::log(ERR, "Failed to find a suitable socket for XWayland");
+ Log::logger->log(Log::ERR, "Failed to find a suitable socket for XWayland");
return false;
}
- Debug::log(LOG, "XWayland found a suitable display socket at DISPLAY: {}", m_displayName);
+ Log::logger->log(Log::DEBUG, "XWayland found a suitable display socket at DISPLAY: {}", m_displayName);
return true;
}
@@ -295,7 +295,7 @@ bool CXWaylandServer::create() {
void CXWaylandServer::runXWayland(CFileDescriptor& notifyFD) {
if (!m_xFDs[0].setFlags(m_xFDs[0].getFlags() & ~FD_CLOEXEC) || !m_xFDs[1].setFlags(m_xFDs[1].getFlags() & ~FD_CLOEXEC) ||
!m_waylandFDs[1].setFlags(m_waylandFDs[1].getFlags() & ~FD_CLOEXEC) || !m_xwmFDs[1].setFlags(m_xwmFDs[1].getFlags() & ~FD_CLOEXEC)) {
- Debug::log(ERR, "Failed to unset cloexec on fds");
+ Log::logger->log(Log::ERR, "Failed to unset cloexec on fds");
_exit(EXIT_FAILURE);
}
@@ -305,11 +305,11 @@ void CXWaylandServer::runXWayland(CFileDescriptor& notifyFD) {
auto waylandSocket = std::format("{}", m_waylandFDs[1].get());
setenv("WAYLAND_SOCKET", waylandSocket.c_str(), true);
- Debug::log(LOG, "Starting XWayland with \"{}\", bon voyage!", cmd);
+ Log::logger->log(Log::DEBUG, "Starting XWayland with \"{}\", bon voyage!", cmd);
execl("/bin/sh", "/bin/sh", "-c", cmd.c_str(), nullptr);
- Debug::log(ERR, "XWayland failed to open");
+ Log::logger->log(Log::ERR, "XWayland failed to open");
_exit(1);
}
@@ -317,7 +317,7 @@ bool CXWaylandServer::start() {
m_idleSource = nullptr;
int wlPair[2] = {-1, -1};
if (socketpair(AF_UNIX, SOCK_STREAM, 0, wlPair) != 0) {
- Debug::log(ERR, "socketpair failed (1)");
+ Log::logger->log(Log::ERR, "socketpair failed (1)");
die();
return false;
}
@@ -325,14 +325,14 @@ bool CXWaylandServer::start() {
m_waylandFDs[1] = CFileDescriptor{wlPair[1]};
if (!m_waylandFDs[0].setFlags(m_waylandFDs[0].getFlags() | FD_CLOEXEC) || !m_waylandFDs[1].setFlags(m_waylandFDs[1].getFlags() | FD_CLOEXEC)) {
- Debug::log(ERR, "set_cloexec failed (1)");
+ Log::logger->log(Log::ERR, "set_cloexec failed (1)");
die();
return false;
}
int xwmPair[2] = {-1, -1};
if (socketpair(AF_UNIX, SOCK_STREAM, 0, xwmPair) != 0) {
- Debug::log(ERR, "socketpair failed (2)");
+ Log::logger->log(Log::ERR, "socketpair failed (2)");
die();
return false;
}
@@ -341,14 +341,14 @@ bool CXWaylandServer::start() {
m_xwmFDs[1] = CFileDescriptor{xwmPair[1]};
if (!m_xwmFDs[0].setFlags(m_xwmFDs[0].getFlags() | FD_CLOEXEC) || !m_xwmFDs[1].setFlags(m_xwmFDs[1].getFlags() | FD_CLOEXEC)) {
- Debug::log(ERR, "set_cloexec failed (2)");
+ Log::logger->log(Log::ERR, "set_cloexec failed (2)");
die();
return false;
}
m_xwaylandClient = wl_client_create(g_pCompositor->m_wlDisplay, m_waylandFDs[0].get());
if (!m_xwaylandClient) {
- Debug::log(ERR, "wl_client_create failed");
+ Log::logger->log(Log::ERR, "wl_client_create failed");
die();
return false;
}
@@ -357,7 +357,7 @@ bool CXWaylandServer::start() {
int notify[2] = {-1, -1};
if (pipe(notify) < 0) {
- Debug::log(ERR, "pipe failed");
+ Log::logger->log(Log::ERR, "pipe failed");
die();
return false;
}
@@ -365,7 +365,7 @@ bool CXWaylandServer::start() {
CFileDescriptor notifyFds[2] = {CFileDescriptor{notify[0]}, CFileDescriptor{notify[1]}};
if (!notifyFds[0].setFlags(notifyFds[0].getFlags() | FD_CLOEXEC)) {
- Debug::log(ERR, "set_cloexec failed (3)");
+ Log::logger->log(Log::ERR, "set_cloexec failed (3)");
die();
return false;
}
@@ -375,7 +375,7 @@ bool CXWaylandServer::start() {
auto serverPID = fork();
if (serverPID < 0) {
- Debug::log(ERR, "fork failed");
+ Log::logger->log(Log::ERR, "fork failed");
die();
return false;
} else if (serverPID == 0) {
@@ -392,7 +392,7 @@ int CXWaylandServer::ready(int fd, uint32_t mask) {
char buf[64];
ssize_t n = read(fd, buf, sizeof(buf));
if (n < 0 && errno != EINTR) {
- Debug::log(ERR, "Xwayland: read from displayFd failed");
+ Log::logger->log(Log::ERR, "Xwayland: read from displayFd failed");
mask = 0;
} else if (n <= 0 || buf[n - 1] != '\n')
return 1;
@@ -400,12 +400,12 @@ int CXWaylandServer::ready(int fd, uint32_t mask) {
// if we don't have readable here, it failed
if (!(mask & WL_EVENT_READABLE)) {
- Debug::log(ERR, "Xwayland: startup failed, not setting up xwm");
+ Log::logger->log(Log::ERR, "Xwayland: startup failed, not setting up xwm");
g_pXWayland->m_server.reset();
return 1;
}
- Debug::log(LOG, "XWayland is ready");
+ Log::logger->log(Log::DEBUG, "XWayland is ready");
wl_event_source_remove(m_pipeSource);
m_pipeFd.reset();