xwayland: Silence X wm debug logging

Much to verbose for default logging.  Use a wm_log() wrapper that we can
toggle on/off as needed.  Maybe we're ready for log domains now.
This commit is contained in:
Kristian Høgsberg 2013-06-18 01:00:27 -04:00
parent 1a81abb1dd
commit 082d58c88d
3 changed files with 126 additions and 69 deletions

View file

@ -1073,6 +1073,10 @@ weston_log_file_open(const char *filename);
void void
weston_log_file_close(void); weston_log_file_close(void);
int int
weston_vlog(const char *fmt, va_list ap);
int
weston_vlog_continue(const char *fmt, va_list ap);
int
weston_log(const char *fmt, ...) weston_log(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));
int int

View file

@ -92,25 +92,45 @@ weston_log_file_close()
weston_logfile = stderr; weston_logfile = stderr;
} }
WL_EXPORT int
weston_vlog(const char *fmt, va_list ap)
{
int l;
l = weston_log_timestamp();
l += vfprintf(weston_logfile, fmt, ap);
return l;
}
WL_EXPORT int WL_EXPORT int
weston_log(const char *fmt, ...) weston_log(const char *fmt, ...)
{ {
int l; int l;
va_list argp; va_list argp;
va_start(argp, fmt); va_start(argp, fmt);
l = weston_log_timestamp(); l = weston_vlog(fmt, argp);
l += vfprintf(weston_logfile, fmt, argp);
va_end(argp); va_end(argp);
return l; return l;
} }
WL_EXPORT int
weston_vlog_continue(const char *fmt, va_list argp)
{
return vfprintf(weston_logfile, fmt, argp);
}
WL_EXPORT int WL_EXPORT int
weston_log_continue(const char *fmt, ...) weston_log_continue(const char *fmt, ...)
{ {
int l; int l;
va_list argp; va_list argp;
va_start(argp, fmt); va_start(argp, fmt);
l = vfprintf(weston_logfile, fmt, argp); l = weston_vlog_continue(fmt, argp);
va_end(argp); va_end(argp);
return l; return l;
} }

View file

@ -124,6 +124,41 @@ get_wm_window(struct weston_surface *surface);
static void static void
weston_wm_window_schedule_repaint(struct weston_wm_window *window); weston_wm_window_schedule_repaint(struct weston_wm_window *window);
static int __attribute__ ((format (printf, 1, 2)))
wm_log(const char *fmt, ...)
{
#ifdef WM_DEBUG
int l;
va_list argp;
va_start(argp, fmt);
l = weston_vlog(fmt, argp);
va_end(argp);
return l;
#else
return 0;
#endif
}
static int __attribute__ ((format (printf, 1, 2)))
wm_log_continue(const char *fmt, ...)
{
#ifdef WM_DEBUG
int l;
va_list argp;
va_start(argp, fmt);
l = weston_vlog_continue(fmt, argp);
va_end(argp);
return l;
#else
return 0;
#endif
}
const char * const char *
get_atom_name(xcb_connection_t *c, xcb_atom_t atom) get_atom_name(xcb_connection_t *c, xcb_atom_t atom)
{ {
@ -234,22 +269,21 @@ dump_property(struct weston_wm *wm,
int width, len; int width, len;
uint32_t i; uint32_t i;
width = weston_log_continue("%s: ", get_atom_name(wm->conn, property)); width = wm_log_continue("%s: ", get_atom_name(wm->conn, property));
if (reply == NULL) { if (reply == NULL) {
weston_log_continue("(no reply)\n"); wm_log_continue("(no reply)\n");
return; return;
} }
width += weston_log_continue( width += wm_log_continue("%s/%d, length %d (value_len %d): ",
"%s/%d, length %d (value_len %d): ", get_atom_name(wm->conn, reply->type),
get_atom_name(wm->conn, reply->type), reply->format,
reply->format, xcb_get_property_value_length(reply),
xcb_get_property_value_length(reply), reply->value_len);
reply->value_len);
if (reply->type == wm->atom.incr) { if (reply->type == wm->atom.incr) {
incr_value = xcb_get_property_value(reply); incr_value = xcb_get_property_value(reply);
weston_log_continue("%d\n", *incr_value); wm_log_continue("%d\n", *incr_value);
} else if (reply->type == wm->atom.utf8_string || } else if (reply->type == wm->atom.utf8_string ||
reply->type == wm->atom.string) { reply->type == wm->atom.string) {
text_value = xcb_get_property_value(reply); text_value = xcb_get_property_value(reply);
@ -257,23 +291,23 @@ dump_property(struct weston_wm *wm,
len = 40; len = 40;
else else
len = reply->value_len; len = reply->value_len;
weston_log_continue("\"%.*s\"\n", len, text_value); wm_log_continue("\"%.*s\"\n", len, text_value);
} else if (reply->type == XCB_ATOM_ATOM) { } else if (reply->type == XCB_ATOM_ATOM) {
atom_value = xcb_get_property_value(reply); atom_value = xcb_get_property_value(reply);
for (i = 0; i < reply->value_len; i++) { for (i = 0; i < reply->value_len; i++) {
name = get_atom_name(wm->conn, atom_value[i]); name = get_atom_name(wm->conn, atom_value[i]);
if (width + strlen(name) + 2 > 78) { if (width + strlen(name) + 2 > 78) {
weston_log_continue("\n "); wm_log_continue("\n ");
width = 4; width = 4;
} else if (i > 0) { } else if (i > 0) {
width += weston_log_continue(", "); width += wm_log_continue(", ");
} }
width += weston_log_continue("%s", name); width += wm_log_continue("%s", name);
} }
weston_log_continue("\n"); wm_log_continue("\n");
} else { } else {
weston_log_continue("huh?\n"); wm_log_continue("huh?\n");
} }
} }
@ -470,10 +504,10 @@ weston_wm_handle_configure_request(struct weston_wm *wm, xcb_generic_event_t *ev
uint32_t mask, values[16]; uint32_t mask, values[16];
int x, y, width, height, i = 0; int x, y, width, height, i = 0;
weston_log("XCB_CONFIGURE_REQUEST (window %d) %d,%d @ %dx%d\n", wm_log("XCB_CONFIGURE_REQUEST (window %d) %d,%d @ %dx%d\n",
configure_request->window, configure_request->window,
configure_request->x, configure_request->y, configure_request->x, configure_request->y,
configure_request->width, configure_request->height); configure_request->width, configure_request->height);
window = hash_table_lookup(wm->window_hash, configure_request->window); window = hash_table_lookup(wm->window_hash, configure_request->window);
@ -526,11 +560,11 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, xcb_generic_event_t *eve
window = hash_table_lookup(wm->window_hash, configure_notify->window); window = hash_table_lookup(wm->window_hash, configure_notify->window);
weston_log("XCB_CONFIGURE_NOTIFY (%s window %d) %d,%d @ %dx%d\n", wm_log("XCB_CONFIGURE_NOTIFY (%s window %d) %d,%d @ %dx%d\n",
configure_notify->window == window->id ? "client" : "frame", configure_notify->window == window->id ? "client" : "frame",
configure_notify->window, configure_notify->window,
configure_notify->x, configure_notify->y, configure_notify->x, configure_notify->y,
configure_notify->width, configure_notify->height); configure_notify->width, configure_notify->height);
/* resize falls here */ /* resize falls here */
if (configure_notify->window != window->id) if (configure_notify->window != window->id)
@ -698,8 +732,8 @@ weston_wm_handle_map_request(struct weston_wm *wm, xcb_generic_event_t *event)
int x, y, width, height; int x, y, width, height;
if (our_resource(wm, map_request->window)) { if (our_resource(wm, map_request->window)) {
weston_log("XCB_MAP_REQUEST (window %d, ours)\n", wm_log("XCB_MAP_REQUEST (window %d, ours)\n",
map_request->window); map_request->window);
return; return;
} }
@ -746,8 +780,8 @@ weston_wm_handle_map_request(struct weston_wm *wm, xcb_generic_event_t *event)
xcb_configure_window(wm->conn, window->id, xcb_configure_window(wm->conn, window->id,
XCB_CONFIG_WINDOW_BORDER_WIDTH, values); XCB_CONFIG_WINDOW_BORDER_WIDTH, values);
weston_log("XCB_MAP_REQUEST (window %d, %p, frame %d)\n", wm_log("XCB_MAP_REQUEST (window %d, %p, frame %d)\n",
window->id, window, window->frame_id); window->id, window, window->frame_id);
weston_wm_window_set_wm_state(window, ICCCM_NORMAL_STATE); weston_wm_window_set_wm_state(window, ICCCM_NORMAL_STATE);
weston_wm_window_set_net_wm_state(window); weston_wm_window_set_net_wm_state(window);
@ -771,12 +805,12 @@ weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
xcb_map_notify_event_t *map_notify = (xcb_map_notify_event_t *) event; xcb_map_notify_event_t *map_notify = (xcb_map_notify_event_t *) event;
if (our_resource(wm, map_notify->window)) { if (our_resource(wm, map_notify->window)) {
weston_log("XCB_MAP_NOTIFY (window %d, ours)\n", wm_log("XCB_MAP_NOTIFY (window %d, ours)\n",
map_notify->window); map_notify->window);
return; return;
} }
weston_log("XCB_MAP_NOTIFY (window %d)\n", map_notify->window); wm_log("XCB_MAP_NOTIFY (window %d)\n", map_notify->window);
} }
static void static void
@ -786,10 +820,10 @@ weston_wm_handle_unmap_notify(struct weston_wm *wm, xcb_generic_event_t *event)
(xcb_unmap_notify_event_t *) event; (xcb_unmap_notify_event_t *) event;
struct weston_wm_window *window; struct weston_wm_window *window;
weston_log("XCB_UNMAP_NOTIFY (window %d, event %d%s)\n", wm_log("XCB_UNMAP_NOTIFY (window %d, event %d%s)\n",
unmap_notify->window, unmap_notify->window,
unmap_notify->event, unmap_notify->event,
our_resource(wm, unmap_notify->window) ? ", ours" : ""); our_resource(wm, unmap_notify->window) ? ", ours" : "");
if (our_resource(wm, unmap_notify->window)) if (our_resource(wm, unmap_notify->window))
return; return;
@ -925,10 +959,9 @@ weston_wm_handle_property_notify(struct weston_wm *wm, xcb_generic_event_t *even
window->properties_dirty = 1; window->properties_dirty = 1;
weston_log("XCB_PROPERTY_NOTIFY: window %d, ", wm_log("XCB_PROPERTY_NOTIFY: window %d, ", property_notify->window);
property_notify->window);
if (property_notify->state == XCB_PROPERTY_DELETE) if (property_notify->state == XCB_PROPERTY_DELETE)
weston_log("deleted\n"); wm_log("deleted\n");
else else
read_and_dump_property(wm, property_notify->window, read_and_dump_property(wm, property_notify->window,
property_notify->atom); property_notify->atom);
@ -947,7 +980,7 @@ weston_wm_window_create(struct weston_wm *wm,
window = malloc(sizeof *window); window = malloc(sizeof *window);
if (window == NULL) { if (window == NULL) {
weston_log("failed to allocate window\n"); wm_log("failed to allocate window\n");
return; return;
} }
@ -978,11 +1011,11 @@ weston_wm_handle_create_notify(struct weston_wm *wm, xcb_generic_event_t *event)
xcb_create_notify_event_t *create_notify = xcb_create_notify_event_t *create_notify =
(xcb_create_notify_event_t *) event; (xcb_create_notify_event_t *) event;
weston_log("XCB_CREATE_NOTIFY (window %d, width %d, height %d%s%s)\n", wm_log("XCB_CREATE_NOTIFY (window %d, width %d, height %d%s%s)\n",
create_notify->window, create_notify->window,
create_notify->width, create_notify->height, create_notify->width, create_notify->height,
create_notify->override_redirect ? ", override" : "", create_notify->override_redirect ? ", override" : "",
our_resource(wm, create_notify->window) ? ", ours" : ""); our_resource(wm, create_notify->window) ? ", ours" : "");
if (our_resource(wm, create_notify->window)) if (our_resource(wm, create_notify->window))
return; return;
@ -999,10 +1032,10 @@ weston_wm_handle_destroy_notify(struct weston_wm *wm, xcb_generic_event_t *event
(xcb_destroy_notify_event_t *) event; (xcb_destroy_notify_event_t *) event;
struct weston_wm_window *window; struct weston_wm_window *window;
weston_log("XCB_DESTROY_NOTIFY, win %d, event %d%s\n", wm_log("XCB_DESTROY_NOTIFY, win %d, event %d%s\n",
destroy_notify->window, destroy_notify->window,
destroy_notify->event, destroy_notify->event,
our_resource(wm, destroy_notify->window) ? ", ours" : ""); our_resource(wm, destroy_notify->window) ? ", ours" : "");
if (our_resource(wm, destroy_notify->window)) if (our_resource(wm, destroy_notify->window))
return; return;
@ -1018,10 +1051,10 @@ weston_wm_handle_reparent_notify(struct weston_wm *wm, xcb_generic_event_t *even
(xcb_reparent_notify_event_t *) event; (xcb_reparent_notify_event_t *) event;
struct weston_wm_window *window; struct weston_wm_window *window;
weston_log("XCB_REPARENT_NOTIFY (window %d, parent %d, event %d)\n", wm_log("XCB_REPARENT_NOTIFY (window %d, parent %d, event %d)\n",
reparent_notify->window, reparent_notify->window,
reparent_notify->parent, reparent_notify->parent,
reparent_notify->event); reparent_notify->event);
if (reparent_notify->parent == wm->screen->root) { if (reparent_notify->parent == wm->screen->root) {
weston_wm_window_create(wm, reparent_notify->window, 10, 10, weston_wm_window_create(wm, reparent_notify->window, 10, 10,
@ -1159,14 +1192,14 @@ weston_wm_handle_client_message(struct weston_wm *wm,
window = hash_table_lookup(wm->window_hash, client_message->window); window = hash_table_lookup(wm->window_hash, client_message->window);
weston_log("XCB_CLIENT_MESSAGE (%s %d %d %d %d %d win %d)\n", wm_log("XCB_CLIENT_MESSAGE (%s %d %d %d %d %d win %d)\n",
get_atom_name(wm->conn, client_message->type), get_atom_name(wm->conn, client_message->type),
client_message->data.data32[0], client_message->data.data32[0],
client_message->data.data32[1], client_message->data.data32[1],
client_message->data.data32[2], client_message->data.data32[2],
client_message->data.data32[3], client_message->data.data32[3],
client_message->data.data32[4], client_message->data.data32[4],
client_message->window); client_message->window);
if (client_message->type == wm->atom.net_wm_moveresize) if (client_message->type == wm->atom.net_wm_moveresize)
weston_wm_window_handle_moveresize(window, client_message); weston_wm_window_handle_moveresize(window, client_message);
@ -1281,9 +1314,9 @@ weston_wm_handle_button(struct weston_wm *wm, xcb_generic_event_t *event)
struct theme *t = wm->theme; struct theme *t = wm->theme;
int width, height; int width, height;
weston_log("XCB_BUTTON_%s (detail %d)\n", wm_log("XCB_BUTTON_%s (detail %d)\n",
button->response_type == XCB_BUTTON_PRESS ? button->response_type == XCB_BUTTON_PRESS ?
"PRESS" : "RELEASE", button->detail); "PRESS" : "RELEASE", button->detail);
window = hash_table_lookup(wm->window_hash, button->event); window = hash_table_lookup(wm->window_hash, button->event);
weston_wm_window_get_frame_size(window, &width, &height); weston_wm_window_get_frame_size(window, &width, &height);
@ -1418,7 +1451,7 @@ weston_wm_handle_event(int fd, uint32_t mask, void *data)
weston_wm_handle_destroy_notify(wm, event); weston_wm_handle_destroy_notify(wm, event);
break; break;
case XCB_MAPPING_NOTIFY: case XCB_MAPPING_NOTIFY:
weston_log("XCB_MAPPING_NOTIFY\n"); wm_log("XCB_MAPPING_NOTIFY\n");
break; break;
case XCB_PROPERTY_NOTIFY: case XCB_PROPERTY_NOTIFY:
weston_wm_handle_property_notify(wm, event); weston_wm_handle_property_notify(wm, event);
@ -1758,7 +1791,7 @@ surface_destroy(struct wl_listener *listener, void *data)
container_of(listener, container_of(listener,
struct weston_wm_window, surface_destroy_listener); struct weston_wm_window, surface_destroy_listener);
weston_log("surface for xid %d destroyed\n", window->id); wm_log("surface for xid %d destroyed\n", window->id);
} }
static struct weston_wm_window * static struct weston_wm_window *
@ -1894,7 +1927,7 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
return; return;
} }
weston_log("set_window_id %d for surface %p\n", id, surface); wm_log("set_window_id %d for surface %p\n", id, surface);
weston_wm_window_read_properties(window); weston_wm_window_read_properties(window);