weston-log: Rename scope's 'begin_cb' callback to 'new_subscriber'

Rather than using 'begin_cb' rename it to a more suitable name.

Further more instead of using the scope use the subscription to pass as
an argument. The source scope is attached to the subscription when
creating it so we can access it that way.

This also adds a _complete and a _printf method for the subscription
such that the callbacks can use to write data to only _that_
subscription and to close/complete it, otherwise writing to a scope
results in writing to all subscriptions for that scope which is not
correct.

In the same time, the scope counter-parts of _write and _complete will
now use the subscription function as well.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Marius Vlad
2019-07-17 15:43:53 +03:00
parent 5ae0e621be
commit dad882a12e
4 changed files with 91 additions and 26 deletions
+11 -3
View File
@@ -38,6 +38,7 @@ struct weston_compositor;
struct weston_log_context;
struct wl_display;
struct weston_log_subscriber;
struct weston_log_subscription;
void
weston_compositor_enable_debug_protocol(struct weston_compositor *);
@@ -56,14 +57,14 @@ struct weston_debug_stream;
*
* @memberof weston_log_scope
*/
typedef void (*weston_log_scope_cb)(struct weston_log_scope *scope,
void *user_data);
typedef void (*weston_log_scope_cb)(struct weston_log_subscription *sub,
void *user_data);
struct weston_log_scope *
weston_compositor_add_log_scope(struct weston_log_context *compositor,
const char *name,
const char *description,
weston_log_scope_cb begin_cb,
weston_log_scope_cb new_subscriber,
void *user_data);
void
@@ -85,8 +86,15 @@ weston_log_scope_printf(struct weston_log_scope *scope,
const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
void
weston_log_subscription_printf(struct weston_log_subscription *scope,
const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
void
weston_log_scope_complete(struct weston_log_scope *scope);
void
weston_log_subscription_complete(struct weston_log_subscription *sub);
char *
weston_log_scope_timestamp(struct weston_log_scope *scope,
char *buf, size_t len);