weston-log: Introduce subscribe functionality

As described in e10c9f89826bb: "weston-debug: Introduce...", the
subscriber object need further functionality to make use of it.

Current form of the weston-debug protocol would not need this, as it
creates underneath a new subscriber each time a client connects and
subscriptions are created/destroyed automatically with the help of
wayland protocol. For other types of streams, we require to manually
create a subscriber and to subscribe to log scopes.

This patch introduces the ability to create subscriptions, and
implicitly to subscribe to (previously created) scopes.

In the event the scope(s) are not created we temporary store the
subscription as a pending one: a subscription for which a scope doesn't
exist at the time of the subscription. When the scope for which the
subscription has been created we take care to create the subscription as
well.

While at it the documentation bits are modified accommodate the subscribe
method and its further functionality.

Lastly, it removes an unlikely case when a scope is not created so we
avoid any kind of dandling (pending) subscription in case there is
subscription to it. We can only do something about in the destroy part
of the scope.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Marius Vlad
2019-06-22 00:29:31 +03:00
parent c901e8913e
commit 9f71a4ad85
2 changed files with 181 additions and 30 deletions
+6
View File
@@ -37,6 +37,7 @@ extern "C" {
struct weston_compositor;
struct weston_log_context;
struct wl_display;
struct weston_log_subscriber;
void
weston_compositor_enable_debug_protocol(struct weston_compositor *);
@@ -90,6 +91,11 @@ char *
weston_log_scope_timestamp(struct weston_log_scope *scope,
char *buf, size_t len);
void
weston_log_subscribe(struct weston_log_context *log_ctx,
struct weston_log_subscriber *subscriber,
const char *scope_name);
#ifdef __cplusplus
}
#endif