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.
dev
Kristian Høgsberg 12 years ago
parent 1a81abb1dd
commit 082d58c88d
  1. 4
      src/compositor.h
  2. 26
      src/log.c
  3. 93
      src/xwayland/window-manager.c

@ -1073,6 +1073,10 @@ weston_log_file_open(const char *filename);
void
weston_log_file_close(void);
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, ...)
__attribute__ ((format (printf, 1, 2)));
int

@ -92,25 +92,45 @@ weston_log_file_close()
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
weston_log(const char *fmt, ...)
{
int l;
va_list argp;
va_start(argp, fmt);
l = weston_log_timestamp();
l += vfprintf(weston_logfile, fmt, argp);
l = weston_vlog(fmt, argp);
va_end(argp);
return l;
}
WL_EXPORT int
weston_vlog_continue(const char *fmt, va_list argp)
{
return vfprintf(weston_logfile, fmt, argp);
}
WL_EXPORT int
weston_log_continue(const char *fmt, ...)
{
int l;
va_list argp;
va_start(argp, fmt);
l = vfprintf(weston_logfile, fmt, argp);
l = weston_vlog_continue(fmt, argp);
va_end(argp);
return l;
}

@ -124,6 +124,41 @@ get_wm_window(struct weston_surface *surface);
static void
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 *
get_atom_name(xcb_connection_t *c, xcb_atom_t atom)
{
@ -234,14 +269,13 @@ dump_property(struct weston_wm *wm,
int width, len;
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) {
weston_log_continue("(no reply)\n");
wm_log_continue("(no reply)\n");
return;
}
width += weston_log_continue(
"%s/%d, length %d (value_len %d): ",
width += wm_log_continue("%s/%d, length %d (value_len %d): ",
get_atom_name(wm->conn, reply->type),
reply->format,
xcb_get_property_value_length(reply),
@ -249,7 +283,7 @@ dump_property(struct weston_wm *wm,
if (reply->type == wm->atom.incr) {
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 ||
reply->type == wm->atom.string) {
text_value = xcb_get_property_value(reply);
@ -257,23 +291,23 @@ dump_property(struct weston_wm *wm,
len = 40;
else
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) {
atom_value = xcb_get_property_value(reply);
for (i = 0; i < reply->value_len; i++) {
name = get_atom_name(wm->conn, atom_value[i]);
if (width + strlen(name) + 2 > 78) {
weston_log_continue("\n ");
wm_log_continue("\n ");
width = 4;
} 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 {
weston_log_continue("huh?\n");
wm_log_continue("huh?\n");
}
}
@ -470,7 +504,7 @@ weston_wm_handle_configure_request(struct weston_wm *wm, xcb_generic_event_t *ev
uint32_t mask, values[16];
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->x, configure_request->y,
configure_request->width, configure_request->height);
@ -526,7 +560,7 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, xcb_generic_event_t *eve
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,
configure_notify->x, configure_notify->y,
@ -698,7 +732,7 @@ weston_wm_handle_map_request(struct weston_wm *wm, xcb_generic_event_t *event)
int x, y, width, height;
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);
return;
}
@ -746,7 +780,7 @@ weston_wm_handle_map_request(struct weston_wm *wm, xcb_generic_event_t *event)
xcb_configure_window(wm->conn, window->id,
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);
weston_wm_window_set_wm_state(window, ICCCM_NORMAL_STATE);
@ -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;
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);
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
@ -786,7 +820,7 @@ weston_wm_handle_unmap_notify(struct weston_wm *wm, xcb_generic_event_t *event)
(xcb_unmap_notify_event_t *) event;
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->event,
our_resource(wm, unmap_notify->window) ? ", ours" : "");
@ -925,10 +959,9 @@ weston_wm_handle_property_notify(struct weston_wm *wm, xcb_generic_event_t *even
window->properties_dirty = 1;
weston_log("XCB_PROPERTY_NOTIFY: window %d, ",
property_notify->window);
wm_log("XCB_PROPERTY_NOTIFY: window %d, ", property_notify->window);
if (property_notify->state == XCB_PROPERTY_DELETE)
weston_log("deleted\n");
wm_log("deleted\n");
else
read_and_dump_property(wm, property_notify->window,
property_notify->atom);
@ -947,7 +980,7 @@ weston_wm_window_create(struct weston_wm *wm,
window = malloc(sizeof *window);
if (window == NULL) {
weston_log("failed to allocate window\n");
wm_log("failed to allocate window\n");
return;
}
@ -978,7 +1011,7 @@ 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 *) 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->width, create_notify->height,
create_notify->override_redirect ? ", override" : "",
@ -999,7 +1032,7 @@ weston_wm_handle_destroy_notify(struct weston_wm *wm, xcb_generic_event_t *event
(xcb_destroy_notify_event_t *) event;
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->event,
our_resource(wm, destroy_notify->window) ? ", ours" : "");
@ -1018,7 +1051,7 @@ weston_wm_handle_reparent_notify(struct weston_wm *wm, xcb_generic_event_t *even
(xcb_reparent_notify_event_t *) event;
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->parent,
reparent_notify->event);
@ -1159,7 +1192,7 @@ weston_wm_handle_client_message(struct weston_wm *wm,
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),
client_message->data.data32[0],
client_message->data.data32[1],
@ -1281,7 +1314,7 @@ weston_wm_handle_button(struct weston_wm *wm, xcb_generic_event_t *event)
struct theme *t = wm->theme;
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 ?
"PRESS" : "RELEASE", button->detail);
@ -1418,7 +1451,7 @@ weston_wm_handle_event(int fd, uint32_t mask, void *data)
weston_wm_handle_destroy_notify(wm, event);
break;
case XCB_MAPPING_NOTIFY:
weston_log("XCB_MAPPING_NOTIFY\n");
wm_log("XCB_MAPPING_NOTIFY\n");
break;
case XCB_PROPERTY_NOTIFY:
weston_wm_handle_property_notify(wm, event);
@ -1758,7 +1791,7 @@ surface_destroy(struct wl_listener *listener, void *data)
container_of(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 *
@ -1894,7 +1927,7 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
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);

Loading…
Cancel
Save