aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-08-28 19:19:31 +0200
committerSimon Ser <contact@emersion.fr>2020-09-01 12:09:25 +0200
commit971de474f0a423cc8f444c92d2e1a8334db8b55d (patch)
tree4abcbbd4fbbf9408e2807d204fb4c8363e53b651
parent65abd4e92af497bbe1ae1085fa16b1b811a3c652 (diff)
backend/session/libseat: register log handler
Route libseat errors through wlroots logging infrastructure. This requires libseat 0.2.0.
-rw-r--r--backend/session/libseat.c25
-rw-r--r--backend/session/meson.build2
2 files changed, 26 insertions, 1 deletions
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