1 From 82b05408e5ed8a8651a99b2dcc61a24c108d48f1 Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Fri, 5 May 2023 11:33:40 +0300
4 Subject: [PATCH] libweston/weston-log: Add an iterator for going over scope
7 libweston users, with the weston-debug protocol doesn't have a way
8 to list the debug scopes. This adds an iterator function to browse
9 over the opaque weston_log_scope.
11 This also adds two helper functions to get the scope name and its
14 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
16 include/libweston/weston-log.h | 9 +++++++++
17 libweston/weston-log.c | 36 ++++++++++++++++++++++++++++++++++
18 2 files changed, 45 insertions(+)
20 diff --git a/include/libweston/weston-log.h b/include/libweston/weston-log.h
21 index aeb7768bf..846cdb089 100644
22 --- a/include/libweston/weston-log.h
23 +++ b/include/libweston/weston-log.h
24 @@ -131,9 +131,18 @@ struct weston_log_subscription *
25 weston_log_subscription_iterate(struct weston_log_scope *scope,
26 struct weston_log_subscription *sub_iter);
28 +struct weston_log_scope *
29 +weston_log_scopes_iterate(struct weston_compositor *compositor,
30 + struct weston_log_scope *nscope);
32 weston_log_flight_recorder_display_buffer(FILE *file);
35 +weston_log_scope_get_description(struct weston_log_scope *scope);
38 +weston_log_scope_get_name(struct weston_log_scope *scope);
43 diff --git a/libweston/weston-log.c b/libweston/weston-log.c
44 index 276fde267..957c30c56 100644
45 --- a/libweston/weston-log.c
46 +++ b/libweston/weston-log.c
47 @@ -1009,3 +1009,39 @@ weston_log_subscription_iterate(struct weston_log_scope *scope,
49 return container_of(node, struct weston_log_subscription, source_link);
52 +WL_EXPORT struct weston_log_scope *
53 +weston_log_scopes_iterate(struct weston_compositor *compositor,
54 + struct weston_log_scope *nscope)
56 + struct weston_log_context *log_ctx = compositor->weston_log_ctx;
57 + struct wl_list *list;
58 + struct wl_list *node;
62 + list = &log_ctx->scope_list;
65 + node = nscope->compositor_link.next;
73 + return container_of(node, struct weston_log_scope, compositor_link);
76 +WL_EXPORT const char *
77 +weston_log_scope_get_name(struct weston_log_scope *scope)
82 +WL_EXPORT const char *
83 +weston_log_scope_get_description(struct weston_log_scope *scope)