From 95ac3e99242b4e7f59f00dd073ede405ff8e9e26 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Fri, 31 May 2024 21:45:55 +0300 Subject: [PATCH] backend/drm: add libliftoff log handler --- backend/drm/libliftoff.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backend/drm/libliftoff.c b/backend/drm/libliftoff.c index 74d4f769..d95e94a9 100644 --- a/backend/drm/libliftoff.c +++ b/backend/drm/libliftoff.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -10,9 +11,28 @@ #include "backend/drm/iface.h" #include "config.h" +static void log_handler(enum liftoff_log_priority priority, const char *fmt, va_list args) { + enum wlr_log_importance importance; + switch (priority) { + case LIFTOFF_SILENT: + importance = WLR_SILENT; + break; + case LIFTOFF_ERROR: + importance = WLR_ERROR; + break; + case LIFTOFF_DEBUG: + importance = WLR_DEBUG; + break; + } + char buf[1024]; + vsnprintf(buf, sizeof(buf), fmt, args); + _wlr_log(importance, "[libliftoff] %s", buf); +} + static bool init(struct wlr_drm_backend *drm) { // TODO: lower log level liftoff_log_set_priority(LIFTOFF_DEBUG); + liftoff_log_set_handler(log_handler); int drm_fd = fcntl(drm->fd, F_DUPFD_CLOEXEC, 0); if (drm_fd < 0) {