Introduced with e0a858a5f2, commit 'weston-debug: Introduce
weston_log_subscription and weston_log_subscriber objects'. We don't
really return a weston_log_subscription so let's remove it.
Some newer doxygen detects this and we are treating warning as errors.
Fixes#594
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Make stream_destroy() use weston_log_subscriber_release().
This avoids code duplication and allow us to destroy
weston_log_subscriber_get_only_subscription(), since it's
being used only in this case and it's internal.
Calls for weson_log_subscriber_release() leads to
weston_log_debug_wayland_to_destroy(), which should not
send an error event when the stream has already been closed.
Also, stream_destroy() shouldn't lead to an event error, as
it is a wl_resource destroy handler. So close the stream before
calling weston_log_subscriber_release() in stream_destroy()
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
Both weston_log_scope_destroy() and weston_log_subscriber_release()
have calls for destroy_subscription(). We can move this call to
weston_log_subscription_destroy() without losing anything and
avoiding repetition.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
The subscription is directly related to both the log scope and
the subscriber. It makes no sense to destroy one of them and
keep the subscriptions living.
We only had code to destroy subscription with
the destruction of log scopes. Add code to destroy
subscriptions with destruction of subscribers.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
Log subscriber API is not type-safe. File and flight recorder
subscribers are created with functions that return
weston_log_subscriber objects. But there's a problem: to destroy
these objects you have to call the right function for each type
of subscriber, and a user calling the wrong destroy function
wouldn't get a warning.
Merge functions that destroy different types of subscribers, making
the log subscriber API type-safe.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
weston_log_subscriber has a member named destroy. There are
other structs (weston_output, for instance) that have this
member, and by convention it is a pointer to a function
that destroys the struct.
In weston_log_subscriber it is being used to destroy
subscriptions of the debug protocol, and not the subscriber,
so this name is misleading. Rename it to destroy_subscription.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
The function weston_log_ctx_compositor_destroy(), which destroys struct
weston_log_context, takes weston_compositor as argument. We may have a
weston_log_context unlinked from a weston_compositor and currently there
is no way to destroy it.
Add function weston_log_ctx_destroy(), what makes the destruction of
weston_log_context independent of weston_compositor.
With this change, one could destroy a weston_compositor and keep the
related weston_log_context (since now weston_log_context can be destroyed
without the need of a weston_compositor). But if weston_compositor gets
destroyed it's also necessary to destroy weston_log_context::global,
as the debug protocol depends on the compositor. So a listener has been
added to the destroy signal of weston_compositor.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
Since weston_log_ctx_compositor_create() does not have any relation
with weston_compositor, rename it to weston_log_ctx_create().
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
The function weston_log_ctx_compositor_setup() is being called only inside
weston_compositor_create() and it is so tiny that the code gets easier to
follow if it gets folded in weston_compositor_create().
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
If we use the function weston_log_context_add_log_scope()
in non-core code, it's necessary to access
weston_compositor::weston_log_ctx.
This is not ideal, since the goal is to make core structs
(weston_compositor, weston_surface, weston_output, etc)
opaque.
Add function weston_compositor_add_log_scope(), so non-core
users are able to pass weston_compositor as argument instead
of weston_compositor::weston_log_ctx.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
There's a function named weston_compositor_add_log_scope()
but it doesn't take a struct weston_compositor argument.
Rename it to weston_log_ctx_add_log_scope(), as
the log_scope is being added to a log_context.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
There's a function named weston_compositor_log_scope_destroy()
but it doesn't take a struct weston_compositor argument.
Rename it to weston_log_scope_destroy(), as the argument is a
struct weston_log_scope.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
There's a function named weston_compositor_add_log_scope()
but it doesn't take a struct weston_compositor argument.
Rename it to weston_log_ctx_add_log_scope(), as
the log_scope is being added to a log_context.
Also, bump libweston_major to 9.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
pending subscription
It limits to scope name to an exact match.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Helper to retrieve next available subscription as to avoid exposing the
subscription, which is an opaque (internal) class of the logging
framework.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
As 'new_subscription' can create additional objects, 'destroy_subscription'
will be needed when cleaning up.
As this requires a libweston_major bump (noticed by @pq), bump it up to
8.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
The callback is executed when the subscription is created, so it doesn't
really have a proper name.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
When all shared/ headers are included in the same way, we can drop unnecessary
include seach paths from the compiler.
This include style was chosen because it is prevalent in the code base. Doing
anything different would have been a bigger patch.
This also means that we need to keep the project root directory in the include
search path, which means that one could accidentally include private headers
with
#include "libweston/dbus.h"
or even
#include <libweston/dbus.h>
IMO such problem is smaller than the churn caused by any of the alternatives,
and we should be able to catch those in review. We might even be able to catch
those with grep in CI if necessary.
The "bad" include style was found with:
$ for h in shared/*.h; do git grep -F $(basename $h); done | grep -vF '"shared/'
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Adds initial grouping for sphinx/breathe for the logging/debugging
framework. We add a few groups: log (public API), internal-log (private API,
not exported) and debug-protocol, specific to the weston
debug protocol.
In latest version of breathe, '\memberof' command is recognized as such.
But it conflicts with '\ingroup' command and can't be used in the same
time (leading to duplicate symbols), so we follow a simple rule: object
tagging with '\ingroup' then use '\memberof' command for the functions
that work on that object.
There's also a caveat here: we have objects that are private (opaque)
but the functions are public. For those cases we resort to using
'internal-log' for the object (class) and 'log' for the functions.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Avoids a potential dependency on the log scope being set-up before
actually creating the scope. Destroy part of the log context could
suffer from the same issue if the log scope is destroyed before.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
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 avoids duplicated bits, by calling the scopes's callback (if any)
and adding the subscription to the scope's subscription list. Further
more, the scope's name when creating the subscription is not needed so
removed that as well.
In mirror, also inline removing of subscription for scope's subscription
list. Fix a potential corner case when the user can request a
subscription to an invalid scope in stream_destroy().
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
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>
Adds a minimalistic API for managing the subscription object. The
subscribe functionality will be brought in once we re-organize a bit
weston-debug-stream and split it properly. It extends the logging
context with a linked list of potential subscription and adds a linked
list of subscriptions in the log scope.
This patch represents the start of a logging framework for weston. It's
being built around weston-debug, with the intent to superseded it, and
make weston-debug a client of the framework. Further more the logging
framework should replace current logging handler and allow other types
of streams to be used.
Currently present in libweston under weston-debug we have log scopes, debug
streams and a logging context.
With this patch, two (internal) objects are being added: the concept of
a subscriber and the concept of subscription. The subscription object
is a ephemeral object, implicitly managed which is created each time one
would want to a subscribe to a scope. The scope will maintain a list of
subscriptions and will continue to be explicitly managed.
The streams will use the subscriber object as a base class to extend
upon. By doing so it allows to customize the stream with specific
functions that manipulate the underlaying storage. The subscriber object
will require a subscribe function and specific stream functions and like
the scope, will be explicitly managed.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This fixes warnings for weston-debug, input, compositor, log and
linux-explicit-sync. Warnings range from swapping '[in]', '[out]' with
the function arguments to wrong parameter names.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This is no longer needed. Also assert if the context passed is NULL and
compositor log context is already set.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
As we transition towards a more generic API for weston loggging
framework rename weston_debug_compositor to weston_log_context to show
the fact that this is not really debug but a logging context.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This patch allows initialization of weston-debug/log framework much earlier
than weston_compositor, which in turn will provide the option start
logging before weston_compositor has been created.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
The main idea is to make libweston users use the form
#include <libweston/libweston.h>
instead of the plain
#include <compositor.h>
which is prone to name conflicts. This is reflected both in the installed
files, and the internal header search paths so that Weston would use the exact
same form as an external project using libweston would.
The public headers are moved under a new top-level directory include/ to make
them clearly stand out as special (public API).
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
weston_debug is both a libweston API for relaying debugging messages,
and the compositor-debug wayland protocol implementation for accessing those
debug messages from a Wayland client.
weston_debug_compositor_{create,destroy}() are private API, hence not
exported.
Signed-off-by: Pekka Paalanen <pq@iki.fi>
append the debug scope name along with the timestamp in
weston_debug_scope_timestamp API
Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss@in.bosch.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Add explicit advertisement of debug scope names.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>