From 971de474f0a423cc8f444c92d2e1a8334db8b55d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 28 Aug 2020 19:19:31 +0200 Subject: [PATCH] backend/session/libseat: register log handler Route libseat errors through wlroots logging infrastructure. This requires libseat 0.2.0. --- backend/session/libseat.c | 25 +++++++++++++++++++++++++ backend/session/meson.build | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/backend/session/libseat.c b/backend/session/libseat.c index 77226204..751adcd3 100644 --- a/backend/session/libseat.c +++ b/backend/session/libseat.c @@ -62,6 +62,28 @@ static struct libseat_session *libseat_session_from_session( return (struct libseat_session *)base; } +static enum wlr_log_importance libseat_log_level_to_wlr( + enum libseat_log_level level) { + switch (level) { + case LIBSEAT_LOG_LEVEL_ERROR: + return WLR_ERROR; + case LIBSEAT_LOG_LEVEL_INFO: + return WLR_INFO; + default: + return WLR_DEBUG; + } +} + +static void log_libseat(enum libseat_log_level level, + const char *fmt, va_list args) { + enum wlr_log_importance importance = libseat_log_level_to_wlr(level); + + static char wlr_fmt[1024]; + snprintf(wlr_fmt, sizeof(wlr_fmt), "[libseat] %s", fmt); + + _wlr_vlog(importance, wlr_fmt, args); +} + static struct wlr_session *libseat_session_create(struct wl_display *disp) { struct libseat_session *session = calloc(1, sizeof(*session)); if (!session) { @@ -72,6 +94,9 @@ static struct wlr_session *libseat_session_create(struct wl_display *disp) { session_init(&session->base); wl_list_init(&session->devices); + libseat_set_log_handler(log_libseat); + libseat_set_log_level(LIBSEAT_LOG_LEVEL_ERROR); + session->seat = libseat_open_seat(&seat_listener, session); if (session->seat == NULL) { wlr_log_errno(WLR_ERROR, "Unable to create seat"); diff --git a/backend/session/meson.build b/backend/session/meson.build index 4c83685e..140d4105 100644 --- a/backend/session/meson.build +++ b/backend/session/meson.build @@ -65,7 +65,7 @@ endif # libseat -libseat = dependency('libseat', required: get_option('libseat')) +libseat = dependency('libseat', required: get_option('libseat'), version: '>=0.2.0') if libseat.found() wlr_files += files('libseat.c') wlr_deps += libseat