libweston: Rename weston_debug_scope_ to weston_log_scope_

Rename also the functions which work on weston_log_scope.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
dev
Marius Vlad 6 years ago committed by Daniel Stone
parent 5d5e335845
commit 7e4db95373
  1. 30
      compositor/main.c
  2. 8
      libweston/compositor-drm.c
  3. 4
      libweston/compositor.c
  4. 36
      libweston/weston-debug.c
  5. 16
      libweston/weston-debug.h
  6. 4
      xwayland/launcher.c
  7. 12
      xwayland/window-manager.c

@ -163,10 +163,10 @@ custom_handler(const char *fmt, va_list arg)
vfprintf(weston_logfile, fmt, arg2); vfprintf(weston_logfile, fmt, arg2);
va_end(arg2); va_end(arg2);
weston_debug_scope_printf(log_scope, "%s libwayland: ", weston_log_scope_printf(log_scope, "%s libwayland: ",
weston_debug_scope_timestamp(log_scope, weston_log_scope_timestamp(log_scope,
timestr, sizeof timestr)); timestr, sizeof timestr));
weston_debug_scope_vprintf(log_scope, fmt, arg); weston_log_scope_vprintf(log_scope, fmt, arg);
} }
static void static void
@ -203,11 +203,11 @@ vlog(const char *fmt, va_list ap)
va_copy(ap2, ap); va_copy(ap2, ap);
if (weston_debug_scope_is_enabled(log_scope)) { if (weston_log_scope_is_enabled(log_scope)) {
weston_debug_scope_printf(log_scope, "%s ", weston_log_scope_printf(log_scope, "%s ",
weston_debug_scope_timestamp(log_scope, weston_log_scope_timestamp(log_scope,
timestr, sizeof timestr)); timestr, sizeof timestr));
weston_debug_scope_vprintf(log_scope, fmt, ap); weston_log_scope_vprintf(log_scope, fmt, ap);
} }
l = weston_log_timestamp(); l = weston_log_timestamp();
@ -223,7 +223,7 @@ vlog_continue(const char *fmt, va_list argp)
va_list argp2; va_list argp2;
va_copy(argp2, argp); va_copy(argp2, argp);
weston_debug_scope_vprintf(log_scope, fmt, argp2); weston_log_scope_vprintf(log_scope, fmt, argp2);
va_end(argp2); va_end(argp2);
return vfprintf(weston_logfile, fmt, argp); return vfprintf(weston_logfile, fmt, argp);
@ -264,14 +264,14 @@ protocol_log_fn(void *user_data,
int i; int i;
char type; char type;
if (!weston_debug_scope_is_enabled(protocol_scope)) if (!weston_log_scope_is_enabled(protocol_scope))
return; return;
fp = open_memstream(&logstr, &logsize); fp = open_memstream(&logstr, &logsize);
if (!fp) if (!fp)
return; return;
weston_debug_scope_timestamp(protocol_scope, weston_log_scope_timestamp(protocol_scope,
timestr, sizeof timestr); timestr, sizeof timestr);
fprintf(fp, "%s ", timestr); fprintf(fp, "%s ", timestr);
fprintf(fp, "client %p %s ", wl_resource_get_client(res), fprintf(fp, "client %p %s ", wl_resource_get_client(res),
@ -334,7 +334,7 @@ protocol_log_fn(void *user_data,
fprintf(fp, ")\n"); fprintf(fp, ")\n");
if (fclose(fp) == 0) if (fclose(fp) == 0)
weston_debug_scope_write(protocol_scope, logstr, logsize); weston_log_scope_write(protocol_scope, logstr, logsize);
free(logstr); free(logstr);
} }
@ -3039,10 +3039,10 @@ int main(int argc, char *argv[])
} }
segv_compositor = wet.compositor; segv_compositor = wet.compositor;
log_scope = weston_compositor_add_debug_scope(log_ctx, "log", log_scope = weston_compositor_add_log_scope(log_ctx, "log",
"Weston and Wayland log\n", NULL, NULL); "Weston and Wayland log\n", NULL, NULL);
protocol_scope = protocol_scope =
weston_compositor_add_debug_scope(log_ctx, weston_compositor_add_log_scope(log_ctx,
"proto", "proto",
"Wayland protocol dump for all clients.\n", "Wayland protocol dump for all clients.\n",
NULL, NULL); NULL, NULL);
@ -3167,9 +3167,9 @@ out:
if (protologger) if (protologger)
wl_protocol_logger_destroy(protologger); wl_protocol_logger_destroy(protologger);
weston_debug_scope_destroy(protocol_scope); weston_compositor_log_scope_destroy(protocol_scope);
protocol_scope = NULL; protocol_scope = NULL;
weston_debug_scope_destroy(log_scope); weston_compositor_log_scope_destroy(log_scope);
log_scope = NULL; log_scope = NULL;
weston_compositor_destroy(wet.compositor); weston_compositor_destroy(wet.compositor);

@ -114,7 +114,7 @@
* possible type and use a matching format specifier. * possible type and use a matching format specifier.
*/ */
#define drm_debug(b, ...) \ #define drm_debug(b, ...) \
weston_debug_scope_printf((b)->debug, __VA_ARGS__) weston_log_scope_printf((b)->debug, __VA_ARGS__)
#define MAX_CLONED_CONNECTORS 4 #define MAX_CLONED_CONNECTORS 4
@ -3199,7 +3199,7 @@ drm_repaint_begin(struct weston_compositor *compositor)
ret = drm_pending_state_alloc(b); ret = drm_pending_state_alloc(b);
b->repaint_data = ret; b->repaint_data = ret;
if (weston_debug_scope_is_enabled(b->debug)) { if (weston_log_scope_is_enabled(b->debug)) {
char *dbg = weston_compositor_print_scene_graph(compositor); char *dbg = weston_compositor_print_scene_graph(compositor);
drm_debug(b, "[repaint] Beginning repaint; pending_state %p\n", drm_debug(b, "[repaint] Beginning repaint; pending_state %p\n",
ret); ret);
@ -6769,7 +6769,7 @@ drm_destroy(struct weston_compositor *ec)
destroy_sprites(b); destroy_sprites(b);
weston_debug_scope_destroy(b->debug); weston_compositor_log_scope_destroy(b->debug);
b->debug = NULL; b->debug = NULL;
weston_compositor_shutdown(ec); weston_compositor_shutdown(ec);
@ -7499,7 +7499,7 @@ drm_backend_create(struct weston_compositor *compositor,
b->pageflip_timeout = config->pageflip_timeout; b->pageflip_timeout = config->pageflip_timeout;
b->use_pixman_shadow = config->use_pixman_shadow; b->use_pixman_shadow = config->use_pixman_shadow;
b->debug = weston_compositor_add_debug_scope(compositor->weston_log_ctx, b->debug = weston_compositor_add_log_scope(compositor->weston_log_ctx,
"drm-backend", "drm-backend",
"Debug messages from DRM/KMS backend\n", "Debug messages from DRM/KMS backend\n",
NULL, NULL); NULL, NULL);

@ -6889,7 +6889,7 @@ weston_compositor_create(struct wl_display *display,
timeline_key_binding_handler, ec); timeline_key_binding_handler, ec);
ec->debug_scene = ec->debug_scene =
weston_compositor_add_debug_scope(ec->weston_log_ctx, "scene-graph", weston_compositor_add_log_scope(ec->weston_log_ctx, "scene-graph",
"Scene graph details\n", "Scene graph details\n",
debug_scene_graph_cb, debug_scene_graph_cb,
ec); ec);
@ -7194,7 +7194,7 @@ weston_compositor_destroy(struct weston_compositor *compositor)
if (compositor->heads_changed_source) if (compositor->heads_changed_source)
wl_event_source_remove(compositor->heads_changed_source); wl_event_source_remove(compositor->heads_changed_source);
weston_debug_scope_destroy(compositor->debug_scene); weston_compositor_log_scope_destroy(compositor->debug_scene);
compositor->debug_scene = NULL; compositor->debug_scene = NULL;
weston_log_ctx_compositor_destroy(compositor); weston_log_ctx_compositor_destroy(compositor);

@ -54,8 +54,8 @@ struct weston_log_context {
/** weston-log message scope /** weston-log message scope
* *
* This is used for scoping debugging messages. Clients can subscribe to * This is used for scoping logging/debugging messages. Clients can subscribe
* only the scopes they are interested in. A scope is identified by its name * to only the scopes they are interested in. A scope is identified by its name
* (also referred to as debug stream name). * (also referred to as debug stream name).
*/ */
struct weston_log_scope { struct weston_log_scope {
@ -371,7 +371,7 @@ weston_compositor_is_debug_protocol_enabled(struct weston_compositor *wc)
return wc->weston_log_ctx->global != NULL; return wc->weston_log_ctx->global != NULL;
} }
/** Register a new debug stream name, creating a debug scope /** Register a new debug stream name, creating a log scope
* *
* \param log_ctx The weston_log_context where to add. * \param log_ctx The weston_log_context where to add.
* \param name The debug stream/scope name; must not be NULL. * \param name The debug stream/scope name; must not be NULL.
@ -406,7 +406,7 @@ weston_compositor_is_debug_protocol_enabled(struct weston_compositor *wc)
* \sa weston_debug_stream, weston_log_scope_cb * \sa weston_debug_stream, weston_log_scope_cb
*/ */
WL_EXPORT struct weston_log_scope * WL_EXPORT struct weston_log_scope *
weston_compositor_add_debug_scope(struct weston_log_context *log_ctx, weston_compositor_add_log_scope(struct weston_log_context *log_ctx,
const char *name, const char *name,
const char *description, const char *description,
weston_log_scope_cb begin_cb, weston_log_scope_cb begin_cb,
@ -468,7 +468,7 @@ weston_compositor_add_debug_scope(struct weston_log_context *log_ctx,
* \memberof weston_log_scope * \memberof weston_log_scope
*/ */
WL_EXPORT void WL_EXPORT void
weston_debug_scope_destroy(struct weston_log_scope *scope) weston_compositor_log_scope_destroy(struct weston_log_scope *scope)
{ {
struct weston_debug_stream *stream; struct weston_debug_stream *stream;
@ -490,7 +490,7 @@ weston_debug_scope_destroy(struct weston_log_scope *scope)
/** Are there any active subscriptions to the scope? /** Are there any active subscriptions to the scope?
* *
* \param scope The debug scope to check; may be NULL. * \param scope The log scope to check; may be NULL.
* \return True if any streams are open for this scope, false otherwise. * \return True if any streams are open for this scope, false otherwise.
* *
* As printing some debugging messages may be relatively expensive, one * As printing some debugging messages may be relatively expensive, one
@ -510,7 +510,7 @@ weston_debug_scope_destroy(struct weston_log_scope *scope)
* \memberof weston_log_scope * \memberof weston_log_scope
*/ */
WL_EXPORT bool WL_EXPORT bool
weston_debug_scope_is_enabled(struct weston_log_scope *scope) weston_log_scope_is_enabled(struct weston_log_scope *scope)
{ {
if (!scope) if (!scope)
return false; return false;
@ -626,7 +626,7 @@ weston_debug_stream_complete(struct weston_debug_stream *stream)
weston_debug_stream_v1_send_complete(stream->resource); weston_debug_stream_v1_send_complete(stream->resource);
} }
/** Write debug data for a scope /** Write log data for a scope
* *
* \param scope The debug scope to write for; may be NULL, in which case * \param scope The debug scope to write for; may be NULL, in which case
* nothing will be written. * nothing will be written.
@ -641,7 +641,7 @@ weston_debug_stream_complete(struct weston_debug_stream *stream)
* \memberof weston_log_scope * \memberof weston_log_scope
*/ */
WL_EXPORT void WL_EXPORT void
weston_debug_scope_write(struct weston_log_scope *scope, weston_log_scope_write(struct weston_log_scope *scope,
const char *data, size_t len) const char *data, size_t len)
{ {
struct weston_debug_stream *stream; struct weston_debug_stream *stream;
@ -655,7 +655,7 @@ weston_debug_scope_write(struct weston_log_scope *scope,
/** Write a formatted string for a scope (varargs) /** Write a formatted string for a scope (varargs)
* *
* \param scope The debug scope to write for; may be NULL, in which case * \param scope The log scope to write for; may be NULL, in which case
* nothing will be written. * nothing will be written.
* \param fmt Printf-style format string. * \param fmt Printf-style format string.
* \param ap Formatting arguments. * \param ap Formatting arguments.
@ -668,28 +668,28 @@ weston_debug_scope_write(struct weston_log_scope *scope,
* \memberof weston_log_scope * \memberof weston_log_scope
*/ */
WL_EXPORT void WL_EXPORT void
weston_debug_scope_vprintf(struct weston_log_scope *scope, weston_log_scope_vprintf(struct weston_log_scope *scope,
const char *fmt, va_list ap) const char *fmt, va_list ap)
{ {
static const char oom[] = "Out of memory"; static const char oom[] = "Out of memory";
char *str; char *str;
int len; int len;
if (!weston_debug_scope_is_enabled(scope)) if (!weston_log_scope_is_enabled(scope))
return; return;
len = vasprintf(&str, fmt, ap); len = vasprintf(&str, fmt, ap);
if (len >= 0) { if (len >= 0) {
weston_debug_scope_write(scope, str, len); weston_log_scope_write(scope, str, len);
free(str); free(str);
} else { } else {
weston_debug_scope_write(scope, oom, sizeof oom - 1); weston_log_scope_write(scope, oom, sizeof oom - 1);
} }
} }
/** Write a formatted string for a scope /** Write a formatted string for a scope
* *
* \param scope The debug scope to write for; may be NULL, in which case * \param scope The log scope to write for; may be NULL, in which case
* nothing will be written. * nothing will be written.
* \param fmt Printf-style format string and arguments. * \param fmt Printf-style format string and arguments.
* *
@ -701,13 +701,13 @@ weston_debug_scope_vprintf(struct weston_log_scope *scope,
* \memberof weston_log_scope * \memberof weston_log_scope
*/ */
WL_EXPORT void WL_EXPORT void
weston_debug_scope_printf(struct weston_log_scope *scope, weston_log_scope_printf(struct weston_log_scope *scope,
const char *fmt, ...) const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
weston_debug_scope_vprintf(scope, fmt, ap); weston_log_scope_vprintf(scope, fmt, ap);
va_end(ap); va_end(ap);
} }
@ -723,7 +723,7 @@ weston_debug_scope_printf(struct weston_log_scope *scope,
* The string is NUL-terminated, even if truncated. * The string is NUL-terminated, even if truncated.
*/ */
WL_EXPORT char * WL_EXPORT char *
weston_debug_scope_timestamp(struct weston_log_scope *scope, weston_log_scope_timestamp(struct weston_log_scope *scope,
char *buf, size_t len) char *buf, size_t len)
{ {
struct timeval tv; struct timeval tv;

@ -51,7 +51,7 @@ struct weston_debug_stream;
* *
* \param stream The debug stream. * \param stream The debug stream.
* \param user_data The \c user_data argument given to * \param user_data The \c user_data argument given to
* weston_compositor_add_debug_scope() * weston_compositor_add_log_scope()
* *
* \memberof weston_log_scope * \memberof weston_log_scope
* \sa weston_debug_stream * \sa weston_debug_stream
@ -60,28 +60,28 @@ typedef void (*weston_log_scope_cb)(struct weston_debug_stream *stream,
void *user_data); void *user_data);
struct weston_log_scope * struct weston_log_scope *
weston_compositor_add_debug_scope(struct weston_log_context *compositor, weston_compositor_add_log_scope(struct weston_log_context *compositor,
const char *name, const char *name,
const char *description, const char *description,
weston_log_scope_cb begin_cb, weston_log_scope_cb begin_cb,
void *user_data); void *user_data);
void void
weston_debug_scope_destroy(struct weston_log_scope *scope); weston_compositor_log_scope_destroy(struct weston_log_scope *scope);
bool bool
weston_debug_scope_is_enabled(struct weston_log_scope *scope); weston_log_scope_is_enabled(struct weston_log_scope *scope);
void void
weston_debug_scope_write(struct weston_log_scope *scope, weston_log_scope_write(struct weston_log_scope *scope,
const char *data, size_t len); const char *data, size_t len);
void void
weston_debug_scope_vprintf(struct weston_log_scope *scope, weston_log_scope_vprintf(struct weston_log_scope *scope,
const char *fmt, va_list ap); const char *fmt, va_list ap);
void void
weston_debug_scope_printf(struct weston_log_scope *scope, weston_log_scope_printf(struct weston_log_scope *scope,
const char *fmt, ...) const char *fmt, ...)
__attribute__ ((format (printf, 2, 3))); __attribute__ ((format (printf, 2, 3)));
@ -102,7 +102,7 @@ void
weston_debug_stream_complete(struct weston_debug_stream *stream); weston_debug_stream_complete(struct weston_debug_stream *stream);
char * char *
weston_debug_scope_timestamp(struct weston_log_scope *scope, weston_log_scope_timestamp(struct weston_log_scope *scope,
char *buf, size_t len); char *buf, size_t len);
#ifdef __cplusplus #ifdef __cplusplus

@ -230,7 +230,7 @@ weston_xserver_destroy(struct wl_listener *l, void *data)
if (wxs->loop) if (wxs->loop)
weston_xserver_shutdown(wxs); weston_xserver_shutdown(wxs);
weston_debug_scope_destroy(wxs->wm_debug); weston_compositor_log_scope_destroy(wxs->wm_debug);
free(wxs); free(wxs);
} }
@ -395,7 +395,7 @@ weston_module_init(struct weston_compositor *compositor)
wl_signal_add(&compositor->destroy_signal, &wxs->destroy_listener); wl_signal_add(&compositor->destroy_signal, &wxs->destroy_listener);
wxs->wm_debug = wxs->wm_debug =
weston_compositor_add_debug_scope(wxs->compositor->weston_log_ctx, weston_compositor_add_log_scope(wxs->compositor->weston_log_ctx,
"xwm-wm-x11", "xwm-wm-x11",
"XWM's window management X11 events\n", "XWM's window management X11 events\n",
NULL, NULL); NULL, NULL);

@ -196,7 +196,7 @@ xserver_map_shell_surface(struct weston_wm_window *window,
static bool static bool
wm_debug_is_enabled(struct weston_wm *wm) wm_debug_is_enabled(struct weston_wm *wm)
{ {
return weston_debug_scope_is_enabled(wm->server->wm_debug); return weston_log_scope_is_enabled(wm->server->wm_debug);
} }
static void __attribute__ ((format (printf, 2, 3))) static void __attribute__ ((format (printf, 2, 3)))
@ -206,12 +206,12 @@ wm_printf(struct weston_wm *wm, const char *fmt, ...)
char timestr[128]; char timestr[128];
if (wm_debug_is_enabled(wm)) if (wm_debug_is_enabled(wm))
weston_debug_scope_printf(wm->server->wm_debug, "%s ", weston_log_scope_printf(wm->server->wm_debug, "%s ",
weston_debug_scope_timestamp(wm->server->wm_debug, weston_log_scope_timestamp(wm->server->wm_debug,
timestr, sizeof timestr)); timestr, sizeof timestr));
va_start(ap, fmt); va_start(ap, fmt);
weston_debug_scope_vprintf(wm->server->wm_debug, fmt, ap); weston_log_scope_vprintf(wm->server->wm_debug, fmt, ap);
va_end(ap); va_end(ap);
} }
static void static void
@ -1379,7 +1379,7 @@ weston_wm_handle_property_notify(struct weston_wm *wm, xcb_generic_event_t *even
if (fp) { if (fp) {
fprintf(fp, "%s XCB_PROPERTY_NOTIFY: window %d, ", fprintf(fp, "%s XCB_PROPERTY_NOTIFY: window %d, ",
weston_debug_scope_timestamp(wm->server->wm_debug, weston_log_scope_timestamp(wm->server->wm_debug,
timestr, sizeof timestr), timestr, sizeof timestr),
property_notify->window); property_notify->window);
if (property_notify->state == XCB_PROPERTY_DELETE) if (property_notify->state == XCB_PROPERTY_DELETE)
@ -1390,7 +1390,7 @@ weston_wm_handle_property_notify(struct weston_wm *wm, xcb_generic_event_t *even
property_notify->atom); property_notify->atom);
if (fclose(fp) == 0) if (fclose(fp) == 0)
weston_debug_scope_write(wm->server->wm_debug, weston_log_scope_write(wm->server->wm_debug,
logstr, logsize); logstr, logsize);
free(logstr); free(logstr);
} else { } else {

Loading…
Cancel
Save