Add API to install protocol loggers on the server wl_display

The new wl_display_add_protocol_logger allows to set a function as
a logger, which will get called when a new request is received or an
event is sent.
This is akin to setting WAYLAND_DEBUG=1, but more powerful because it
can be enabled at run time and allows to show the log e.g. in a UI view.
A test is added for the new functionality.

Signed-off-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Giulio Camuffo 2016-08-12 09:33:06 +02:00 committed by Pekka Paalanen
parent 2f617250d2
commit 450f06e21a
4 changed files with 272 additions and 7 deletions

View file

@ -522,6 +522,30 @@ wl_shm_buffer_create(struct wl_client *client,
void
wl_log_set_handler_server(wl_log_func_t handler);
enum wl_protocol_logger_type {
WL_PROTOCOL_LOGGER_REQUEST,
WL_PROTOCOL_LOGGER_EVENT,
};
struct wl_protocol_logger_message {
struct wl_resource *resource;
int message_opcode;
const struct wl_message *message;
int arguments_count;
const union wl_argument *arguments;
};
typedef void (*wl_protocol_logger_func_t)(void *user_data,
enum wl_protocol_logger_type direction,
const struct wl_protocol_logger_message *message);
struct wl_protocol_logger *
wl_display_add_protocol_logger(struct wl_display *display,
wl_protocol_logger_func_t, void *user_data);
void
wl_protocol_logger_destroy(struct wl_protocol_logger *logger);
#ifdef __cplusplus
}
#endif