[PATCH v2 2/2] Replaced fprintf calls with logging functions.
Ustun Ergenoglu
ustun.ergenoglu at gmail.com
Mon Feb 13 14:30:13 PST 2012
From: Üstün Ergenoğlu <ustun.ergenoglu at gmail.com>
Signed-off-by: Üstün Ergenoğlu <ego at ustun.fi>
---
src/compositor-drm.c | 60 ++++++++++----------
src/compositor-openwfd.c | 37 +++++++------
src/compositor-wayland.c | 27 +++++-----
src/compositor-x11.c | 21 ++++----
src/compositor.c | 57 ++++++++++----------
src/evdev.c | 10 ++--
src/shell.c | 11 ++--
src/tablet-shell.c | 10 ++--
src/tty.c | 29 +++++-----
src/xserver-launcher.c | 136 +++++++++++++++++++++++-----------------------
10 files changed, 199 insertions(+), 199 deletions(-)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index de6feb4..08655fd 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -35,6 +35,7 @@
#include <gbm.h>
#include "compositor.h"
+#include "log.h"
#include "evdev.h"
struct drm_compositor {
@@ -177,7 +178,7 @@ drm_output_repaint(struct weston_output *output_base)
if (drmModePageFlip(compositor->drm.fd, output->crtc_id,
fb_id,
DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
- fprintf(stderr, "queueing pageflip failed: %m\n");
+ WL_LOG_W("queueing pageflip failed: %m");
return;
}
@@ -272,7 +273,7 @@ drm_output_set_cursor(struct weston_output *output_base,
ret = drmModeSetCursor(c->drm.fd, output->crtc_id, handle, 64, 64);
if (ret) {
- fprintf(stderr, "failed to set cursor: %s\n", strerror(-ret));
+ WL_LOG_W("failed to set cursor: %s", strerror(-ret));
goto out;
}
@@ -280,7 +281,7 @@ drm_output_set_cursor(struct weston_output *output_base,
eid->sprite->geometry.x - output->base.x,
eid->sprite->geometry.y - output->base.y);
if (ret) {
- fprintf(stderr, "failed to move cursor: %s\n", strerror(-ret));
+ WL_LOG_W("failed to move cursor: %s", strerror(-ret));
goto out;
}
@@ -361,7 +362,7 @@ init_egl(struct drm_compositor *ec, struct udev_device *device)
fd = open(filename, O_RDWR | O_CLOEXEC);
if (fd < 0) {
/* Probably permissions error */
- fprintf(stderr, "couldn't open %s, skipping\n",
+ WL_LOG_E("couldn't open %s, skipping",
udev_device_get_devnode(device));
return -1;
}
@@ -370,36 +371,36 @@ init_egl(struct drm_compositor *ec, struct udev_device *device)
ec->gbm = gbm_create_device(ec->drm.fd);
ec->base.display = eglGetDisplay(ec->gbm);
if (ec->base.display == NULL) {
- fprintf(stderr, "failed to create display\n");
+ WL_LOG_E("failed to create display");
return -1;
}
if (!eglInitialize(ec->base.display, &major, &minor)) {
- fprintf(stderr, "failed to initialize display\n");
+ WL_LOG_E("failed to initialize display");
return -1;
}
extensions = eglQueryString(ec->base.display, EGL_EXTENSIONS);
if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
- fprintf(stderr, "EGL_KHR_surfaceless_gles2 not available\n");
+ WL_LOG_E("EGL_KHR_surfaceless_gles2 not available");
return -1;
}
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
- fprintf(stderr, "failed to bind api EGL_OPENGL_ES_API\n");
+ WL_LOG_E("failed to bind api EGL_OPENGL_ES_API");
return -1;
}
ec->base.context = eglCreateContext(ec->base.display, NULL,
EGL_NO_CONTEXT, context_attribs);
if (ec->base.context == NULL) {
- fprintf(stderr, "failed to create context\n");
+ WL_LOG_E("failed to create context");
return -1;
}
if (!eglMakeCurrent(ec->base.display, EGL_NO_SURFACE,
EGL_NO_SURFACE, ec->base.context)) {
- fprintf(stderr, "failed to make context current\n");
+ WL_LOG_E("failed to make context current");
return -1;
}
@@ -499,7 +500,7 @@ create_output_for_connector(struct drm_compositor *ec,
encoder = drmModeGetEncoder(ec->drm.fd, connector->encoders[0]);
if (encoder == NULL) {
- fprintf(stderr, "No encoder for connector.\n");
+ WL_LOG_E("No encoder for connector.");
return -1;
}
@@ -509,7 +510,7 @@ create_output_for_connector(struct drm_compositor *ec,
break;
}
if (i == resources->count_crtcs) {
- fprintf(stderr, "No usable crtc for encoder.\n");
+ WL_LOG_E("No usable crtc for encoder.");
drmModeFreeEncoder(encoder);
return -1;
}
@@ -585,7 +586,7 @@ create_output_for_connector(struct drm_compositor *ec,
output->base.current->height,
24, 32, stride, handle, &output->fb_id[i]);
if (ret) {
- fprintf(stderr, "failed to add fb %d: %m\n", i);
+ WL_LOG_E("failed to add fb %d: %m", i);
goto err_bufs;
}
}
@@ -600,7 +601,7 @@ create_output_for_connector(struct drm_compositor *ec,
&output->connector_id, 1,
&drm_mode->mode_info);
if (ret) {
- fprintf(stderr, "failed to set mode: %m\n");
+ WL_LOG_E("failed to set mode: %m");
goto err_fb;
}
@@ -663,7 +664,7 @@ create_outputs(struct drm_compositor *ec, int option_connector)
resources = drmModeGetResources(ec->drm.fd);
if (!resources) {
- fprintf(stderr, "drmModeGetResources failed\n");
+ WL_LOG_E("drmModeGetResources failed");
return -1;
}
@@ -691,7 +692,7 @@ create_outputs(struct drm_compositor *ec, int option_connector)
}
if (wl_list_empty(&ec->base.output_list)) {
- fprintf(stderr, "No currently active connector found.\n");
+ WL_LOG_E("No currently active connector found.");
return -1;
}
@@ -713,7 +714,7 @@ update_outputs(struct drm_compositor *ec)
resources = drmModeGetResources(ec->drm.fd);
if (!resources) {
- fprintf(stderr, "drmModeGetResources failed\n");
+ WL_LOG_E("drmModeGetResources failed");
return;
}
@@ -745,7 +746,7 @@ update_outputs(struct drm_compositor *ec)
y = 0;
create_output_for_connector(ec, resources,
connector, x, y);
- printf("connector %d connected\n", connector_id);
+ WL_LOG_I("connector %d connected", connector_id);
}
drmModeFreeConnector(connector);
@@ -764,7 +765,7 @@ update_outputs(struct drm_compositor *ec)
if (disconnects & (1 << output->connector_id)) {
disconnects &= ~(1 << output->connector_id);
- printf("connector %d disconnected\n",
+ WL_LOG_I("connector %d disconnected",
output->connector_id);
x_offset += output->base.current->width;
drm_output_destroy(&output->base);
@@ -864,8 +865,7 @@ drm_compositor_set_modes(struct drm_compositor *compositor)
&output->connector_id, 1,
&drm_mode->mode_info);
if (ret < 0) {
- fprintf(stderr,
- "failed to set mode %dx%d for output at %d,%d: %m",
+ WL_LOG_E("failed to set mode %dx%d for output at %d,%d: %m",
drm_mode->base.width, drm_mode->base.height,
output->base.x, output->base.y);
}
@@ -883,7 +883,7 @@ vt_func(struct weston_compositor *compositor, int event)
case TTY_ENTER_VT:
compositor->focus = 1;
if (drmSetMaster(ec->drm.fd)) {
- fprintf(stderr, "failed to set master: %m\n");
+ WL_LOG_E("failed to set master: %m");
wl_display_terminate(compositor->wl_display);
}
compositor->state = ec->prev_state;
@@ -914,7 +914,7 @@ vt_func(struct weston_compositor *compositor, int event)
evdev_remove_devices(input);
if (drmDropMaster(ec->drm.fd) < 0)
- fprintf(stderr, "failed to drop master: %m\n");
+ WL_LOG_E("failed to drop master: %m");
break;
};
@@ -940,14 +940,14 @@ drm_compositor_create(struct wl_display *display,
memset(ec, 0, sizeof *ec);
ec->udev = udev_new();
if (ec->udev == NULL) {
- fprintf(stderr, "failed to initialize udev context\n");
+ WL_LOG_E("failed to initialize udev context");
return NULL;
}
ec->base.wl_display = display;
ec->tty = tty_create(&ec->base, vt_func, tty);
if (!ec->tty) {
- fprintf(stderr, "failed to initialize tty\n");
+ WL_LOG_E("failed to initialize tty");
free(ec);
return NULL;
}
@@ -973,12 +973,12 @@ drm_compositor_create(struct wl_display *display,
}
if (drm_device == NULL) {
- fprintf(stderr, "no drm device found\n");
+ WL_LOG_E("no drm device found");
return NULL;
}
if (init_egl(ec, drm_device) < 0) {
- fprintf(stderr, "failed to initialize egl\n");
+ WL_LOG_E("failed to initialize egl");
return NULL;
}
@@ -999,7 +999,7 @@ drm_compositor_create(struct wl_display *display,
return NULL;
if (create_outputs(ec, connector) < 0) {
- fprintf(stderr, "failed to create output for %s\n", path);
+ WL_LOG_E("failed to create output for %s", path);
return NULL;
}
@@ -1015,7 +1015,7 @@ drm_compositor_create(struct wl_display *display,
ec->udev_monitor = udev_monitor_new_from_netlink(ec->udev, "udev");
if (ec->udev_monitor == NULL) {
- fprintf(stderr, "failed to intialize udev monitor\n");
+ WL_LOG_E("failed to intialize udev monitor");
return NULL;
}
udev_monitor_filter_add_match_subsystem_devtype(ec->udev_monitor,
@@ -1026,7 +1026,7 @@ drm_compositor_create(struct wl_display *display,
WL_EVENT_READABLE, udev_drm_event, ec);
if (udev_monitor_enable_receiving(ec->udev_monitor) < 0) {
- fprintf(stderr, "failed to enable udev-monitor receiving\n");
+ WL_LOG_E("failed to enable udev-monitor receiving");
return NULL;
}
diff --git a/src/compositor-openwfd.c b/src/compositor-openwfd.c
index aa4e5a9..6b14e64 100644
--- a/src/compositor-openwfd.c
+++ b/src/compositor-openwfd.c
@@ -35,6 +35,7 @@
#include <gbm.h>
#include "compositor.h"
+#include "log.h"
#include "evdev.h"
struct wfd_compositor {
@@ -137,36 +138,36 @@ init_egl(struct wfd_compositor *ec)
ec->gbm = gbm_create_device(ec->wfd_fd);
ec->base.display = eglGetDisplay(ec->gbm);
if (ec->base.display == NULL) {
- fprintf(stderr, "failed to create display\n");
+ WL_LOG_E("failed to create display");
return -1;
}
if (!eglInitialize(ec->base.display, &major, &minor)) {
- fprintf(stderr, "failed to initialize display\n");
+ WL_LOG_E("failed to initialize display");
return -1;
}
extensions = eglQueryString(ec->base.display, EGL_EXTENSIONS);
if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
- fprintf(stderr, "EGL_KHR_surfaceless_gles2 not available\n");
+ WL_LOG_E("EGL_KHR_surfaceless_gles2 not available");
return -1;
}
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
- fprintf(stderr, "failed to bind api EGL_OPENGL_ES_API\n");
+ WL_LOG_E("failed to bind api EGL_OPENGL_ES_API");
return -1;
}
ec->base.context = eglCreateContext(ec->base.display, NULL,
EGL_NO_CONTEXT, context_attribs);
if (ec->base.context == NULL) {
- fprintf(stderr, "failed to create context\n");
+ WL_LOG_E("failed to create context");
return -1;
}
if (!eglMakeCurrent(ec->base.display, EGL_NO_SURFACE,
EGL_NO_SURFACE, ec->base.context)) {
- fprintf(stderr, "failed to make context current\n");
+ WL_LOG_E("failed to make context current");
return -1;
}
@@ -272,7 +273,7 @@ create_output_for_port(struct wfd_compositor *ec,
num_modes = wfdGetPortModes(ec->dev, output->port, NULL, 0);
if (num_modes < 1) {
- fprintf(stderr, "failed to get port mode\n");
+ WL_LOG_E("failed to get port mode");
goto cleanup_port;
}
@@ -300,7 +301,7 @@ create_output_for_port(struct wfd_compositor *ec,
}
}
if (output->base.current == NULL) {
- fprintf(stderr, "failed to find a native mode\n");
+ WL_LOG_E("failed to find a native mode");
goto cleanup_port;
}
@@ -314,7 +315,7 @@ create_output_for_port(struct wfd_compositor *ec,
num_pipelines = wfdGetPortAttribi(ec->dev, output->port,
WFD_PORT_PIPELINE_ID_COUNT);
if (num_pipelines < 1) {
- fprintf(stderr, "failed to get a bindable pipeline\n");
+ WL_LOG_E("failed to get a bindable pipeline");
goto cleanup_port;
}
pipelines = calloc(num_pipelines, sizeof *pipelines);
@@ -333,7 +334,7 @@ create_output_for_port(struct wfd_compositor *ec,
}
}
if (output->pipeline_id == WFD_INVALID_PIPELINE_ID) {
- fprintf(stderr, "no pipeline found for port: %d\n", port);
+ WL_LOG_E("no pipeline found for port: %d", port);
goto cleanup_pipelines;
}
@@ -348,7 +349,7 @@ create_output_for_port(struct wfd_compositor *ec,
output->pipeline = wfdCreatePipeline(ec->dev, output->pipeline_id, NULL);
if (output->pipeline == WFD_INVALID_HANDLE) {
- fprintf(stderr, "failed to create a pipeline\n");
+ WL_LOG_E("failed to create a pipeline");
goto cleanup_weston_output;
}
@@ -367,7 +368,7 @@ create_output_for_port(struct wfd_compositor *ec,
EGL_NATIVE_PIXMAP_KHR,
output->bo[i], NULL);
- printf("output->image[i]: %p\n", output->image[i]);
+ WL_LOG_D("output->image[i]: %p", output->image[i]);
ec->base.image_target_renderbuffer_storage(GL_RENDERBUFFER,
output->image[i]);
output->source[i] =
@@ -375,7 +376,7 @@ create_output_for_port(struct wfd_compositor *ec,
output->image[i], NULL);
if (output->source[i] == WFD_INVALID_HANDLE) {
- fprintf(stderr, "failed to create source\n");
+ WL_LOG_E("failed to create source");
goto cleanup_pipeline;
}
}
@@ -611,25 +612,25 @@ wfd_compositor_create(struct wl_display *display,
ec->udev = udev_new();
if (ec->udev == NULL) {
- fprintf(stderr, "failed to initialize udev context\n");
+ WL_LOG_E("failed to initialize udev context");
return NULL;
}
ec->dev = wfdCreateDevice(WFD_DEFAULT_DEVICE_ID, NULL);
if (ec->dev == WFD_INVALID_HANDLE) {
- fprintf(stderr, "failed to create wfd device\n");
+ WL_LOG_E("failed to create wfd device");
return NULL;
}
ec->event = wfdCreateEvent(ec->dev, NULL);
if (ec->event == WFD_INVALID_HANDLE) {
- fprintf(stderr, "failed to create wfd event\n");
+ WL_LOG_E("failed to create wfd event");
return NULL;
}
ec->base.wl_display = display;
if (init_egl(ec) < 0) {
- fprintf(stderr, "failed to initialize egl\n");
+ WL_LOG_E("failed to initialize egl");
return NULL;
}
@@ -644,7 +645,7 @@ wfd_compositor_create(struct wl_display *display,
return NULL;
if (create_outputs(ec, connector) < 0) {
- fprintf(stderr, "failed to create outputs\n");
+ WL_LOG_E("failed to create outputs");
return NULL;
}
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 5199622..439ed66 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -41,6 +41,7 @@
#include <EGL/eglext.h>
#include "compositor.h"
+#include "log.h"
struct wayland_compositor {
struct weston_compositor base;
@@ -212,7 +213,7 @@ create_border(struct wayland_compositor *c)
&c->border.width,
&c->border.height, &stride);
if (!pixels) {
- fprintf(stderr, "could'nt load border image\n");
+ WL_LOG_W("could'nt load border image");
return;
}
@@ -274,41 +275,41 @@ wayland_compositor_init_egl(struct wayland_compositor *c)
c->base.display = eglGetDisplay(c->parent.display);
if (c->base.display == NULL) {
- fprintf(stderr, "failed to create display\n");
+ WL_LOG_E("failed to create display");
return -1;
}
if (!eglInitialize(c->base.display, &major, &minor)) {
- fprintf(stderr, "failed to initialize display\n");
+ WL_LOG_E("failed to initialize display");
return -1;
}
extensions = eglQueryString(c->base.display, EGL_EXTENSIONS);
if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
- fprintf(stderr, "EGL_KHR_surfaceless_gles2 not available\n");
+ WL_LOG_E("EGL_KHR_surfaceless_gles2 not available");
return -1;
}
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
- fprintf(stderr, "failed to bind EGL_OPENGL_ES_API\n");
+ WL_LOG_E("failed to bind EGL_OPENGL_ES_API");
return -1;
}
if (!eglChooseConfig(c->base.display, config_attribs,
&c->base.config, 1, &n) || n == 0) {
- fprintf(stderr, "failed to choose config: %d\n", n);
+ WL_LOG_E("failed to choose config: %d", n);
return -1;
}
c->base.context = eglCreateContext(c->base.display, c->base.config,
EGL_NO_CONTEXT, context_attribs);
if (c->base.context == NULL) {
- fprintf(stderr, "failed to create context\n");
+ WL_LOG_E("failed to create context");
return -1;
}
if (!eglMakeCurrent(c->base.display, EGL_NO_SURFACE,
EGL_NO_SURFACE, c->base.context)) {
- fprintf(stderr, "failed to make context current\n");
+ WL_LOG_E("failed to make context current");
return -1;
}
@@ -339,7 +340,7 @@ wayland_output_repaint(struct weston_output *output_base)
if (!eglMakeCurrent(compositor->base.display, output->egl_surface,
output->egl_surface, compositor->base.context)) {
- fprintf(stderr, "failed to make current\n");
+ WL_LOG_W("failed to make current");
return;
}
@@ -414,7 +415,7 @@ wayland_compositor_create_output(struct wayland_compositor *c,
width + c->border.left + c->border.right,
height + c->border.top + c->border.bottom);
if (!output->parent.egl_window) {
- fprintf(stderr, "failure to create wl_egl_window\n");
+ WL_LOG_E("failure to create wl_egl_window");
goto cleanup_output;
}
@@ -422,13 +423,13 @@ wayland_compositor_create_output(struct wayland_compositor *c,
eglCreateWindowSurface(c->base.display, c->base.config,
output->parent.egl_window, NULL);
if (!output->egl_surface) {
- fprintf(stderr, "failed to create window surface\n");
+ WL_LOG_E("failed to create window surface");
goto cleanup_window;
}
if (!eglMakeCurrent(c->base.display, output->egl_surface,
output->egl_surface, c->base.context)) {
- fprintf(stderr, "failed to make surface current\n");
+ WL_LOG_E("failed to make surface current");
goto cleanup_surface;
return -1;
}
@@ -672,7 +673,7 @@ wayland_compositor_create(struct wl_display *display,
c->parent.display = wl_display_connect(display_name);
if (c->parent.display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ WL_LOG_E("failed to create display: %m");
return NULL;
}
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 0e58229..08e7dd0 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -43,6 +43,7 @@
#include <EGL/egl.h>
#include "compositor.h"
+#include "log.h"
struct x11_compositor {
struct weston_compositor base;
@@ -133,41 +134,41 @@ x11_compositor_init_egl(struct x11_compositor *c)
c->base.display = eglGetDisplay(c->dpy);
if (c->base.display == NULL) {
- fprintf(stderr, "failed to create display\n");
+ WL_LOG_E("failed to create display\n");
return -1;
}
if (!eglInitialize(c->base.display, &major, &minor)) {
- fprintf(stderr, "failed to initialize display\n");
+ WL_LOG_E("failed to initialize display\n");
return -1;
}
extensions = eglQueryString(c->base.display, EGL_EXTENSIONS);
if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
- fprintf(stderr, "EGL_KHR_surfaceless_gles2 not available\n");
+ WL_LOG_E("EGL_KHR_surfaceless_gles2 not available\n");
return -1;
}
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
- fprintf(stderr, "failed to bind EGL_OPENGL_ES_API\n");
+ WL_LOG_E("failed to bind EGL_OPENGL_ES_API\n");
return -1;
}
if (!eglChooseConfig(c->base.display, config_attribs,
&c->base.config, 1, &n) || n == 0) {
- fprintf(stderr, "failed to choose config: %d\n", n);
+ WL_LOG_E("failed to choose config: %d\n", n);
return -1;
}
c->base.context = eglCreateContext(c->base.display, c->base.config,
EGL_NO_CONTEXT, context_attribs);
if (c->base.context == NULL) {
- fprintf(stderr, "failed to create context\n");
+ WL_LOG_E("failed to create context\n");
return -1;
}
if (!eglMakeCurrent(c->base.display, EGL_NO_SURFACE,
EGL_NO_SURFACE, c->base.context)) {
- fprintf(stderr, "failed to make context current\n");
+ WL_LOG_E("failed to make context current\n");
return -1;
}
@@ -195,7 +196,7 @@ x11_output_repaint(struct weston_output *output_base)
if (!eglMakeCurrent(compositor->base.display, output->egl_surface,
output->egl_surface, compositor->base.context)) {
- fprintf(stderr, "failed to make current\n");
+ WL_LOG_W("failed to make current\n");
return;
}
@@ -432,12 +433,12 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
eglCreateWindowSurface(c->base.display, c->base.config,
output->window, NULL);
if (!output->egl_surface) {
- fprintf(stderr, "failed to create window surface\n");
+ WL_LOG_E("failed to create window surface\n");
return -1;
}
if (!eglMakeCurrent(c->base.display, output->egl_surface,
output->egl_surface, c->base.context)) {
- fprintf(stderr, "failed to make surface current\n");
+ WL_LOG_E("failed to make surface current\n");
return -1;
}
diff --git a/src/compositor.c b/src/compositor.c
index 7ffadbd..faaa4f9 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -70,7 +70,7 @@ sigchld_handler(int signal_number, void *data)
}
if (&p->link == &child_process_list) {
- fprintf(stderr, "unknown child process exited\n");
+ WL_LOG_W("unknown child process exited");
return 1;
}
@@ -104,7 +104,7 @@ child_client_exec(int sockfd, const char *path)
* non-CLOEXEC fd to pass through exec. */
clientfd = dup(sockfd);
if (clientfd == -1) {
- fprintf(stderr, "compositor: dup failed: %m\n");
+ WL_LOG_W("compositor: dup failed: %m");
return;
}
@@ -112,7 +112,7 @@ child_client_exec(int sockfd, const char *path)
setenv("WAYLAND_SOCKET", s, 1);
if (execl(path, path, NULL) < 0)
- fprintf(stderr, "compositor: executing '%s' failed: %m\n",
+ WL_LOG_W("compositor: executing '%s' failed: %m",
path);
}
@@ -127,8 +127,8 @@ weston_client_launch(struct weston_compositor *compositor,
struct wl_client *client;
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
- fprintf(stderr, "weston_client_launch: "
- "socketpair failed while launching '%s': %m\n",
+ WL_LOG_E("weston_client_launch: "
+ "socketpair failed while launching '%s': %m",
path);
return NULL;
}
@@ -137,8 +137,8 @@ weston_client_launch(struct weston_compositor *compositor,
if (pid == -1) {
close(sv[0]);
close(sv[1]);
- fprintf(stderr, "weston_client_launch: "
- "fork failed while launching '%s': %m\n", path);
+ WL_LOG_E("weston_client_launch: "
+ "fork failed while launching '%s': %m", path);
return NULL;
}
@@ -152,8 +152,8 @@ weston_client_launch(struct weston_compositor *compositor,
client = wl_client_create(compositor->wl_display, sv[0]);
if (!client) {
close(sv[0]);
- fprintf(stderr, "weston_client_launch: "
- "wl_client_create failed while launching '%s'.\n",
+ WL_LOG_E("weston_client_launch: "
+ "wl_client_create failed while launching '%s'.",
path);
return NULL;
}
@@ -241,7 +241,7 @@ surface_to_global_float(struct weston_surface *surface,
weston_matrix_transform(&surface->transform.matrix, &v);
if (fabsf(v.f[3]) < 1e-6) {
- fprintf(stderr, "warning: numerical instability in "
+ WL_LOG_W("warning: numerical instability in "
"weston_surface_to_global(), divisor = %g\n",
v.f[3]);
*x = 0;
@@ -343,8 +343,9 @@ weston_surface_update_transform_enable(struct weston_surface *surface)
if (weston_matrix_invert(inverse, matrix) < 0) {
/* Oops, bad total transformation, not invertible */
- fprintf(stderr, "error: weston_surface %p"
- " transformation not invertible.\n", surface);
+ surface->transform.enabled = 0;
+ WL_LOG_W("error: weston_surface %p"
+ " transformation not invertible.", surface);
return -1;
}
@@ -422,8 +423,8 @@ surface_from_global_float(struct weston_surface *surface,
weston_matrix_transform(&surface->transform.inverse, &v);
if (fabsf(v.f[3]) < 1e-6) {
- fprintf(stderr, "warning: numerical instability in "
- "weston_surface_from_global(), divisor = %g\n",
+ WL_LOG_W("warning: numerical instability in "
+ "weston_surface_from_global(), divisor = %g",
v.f[3]);
*sx = 0;
*sy = 0;
@@ -767,7 +768,7 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output)
glDisable(GL_BLEND);
break;
default:
- fprintf(stderr, "bogus visual\n");
+ WL_LOG_W("bogus visual");
break;
}
@@ -1597,7 +1598,7 @@ touch_set_focus(struct weston_input_device *device,
find_resource_for_surface(&input_device->resource_list,
surface);
if (!resource) {
- fprintf(stderr, "couldn't find resource\n");
+ WL_LOG_W("couldn't find resource");
return;
}
@@ -1861,7 +1862,7 @@ compile_shader(GLenum type, const char *source)
glGetShaderiv(s, GL_COMPILE_STATUS, &status);
if (!status) {
glGetShaderInfoLog(s, sizeof msg, NULL, msg);
- fprintf(stderr, "shader info: %s\n", msg);
+ WL_LOG_E("shader info: %s", msg);
return GL_NONE;
}
@@ -1890,7 +1891,7 @@ weston_shader_init(struct weston_shader *shader,
glGetProgramiv(shader->program, GL_LINK_STATUS, &status);
if (!status) {
glGetProgramInfoLog(shader->program, sizeof msg, NULL, msg);
- fprintf(stderr, "link info: %s\n", msg);
+ WL_LOG_E("link info: %s", msg);
return -1;
}
@@ -2052,8 +2053,7 @@ weston_compositor_init(struct weston_compositor *ec, struct wl_display *display)
extensions = (const char *) glGetString(GL_EXTENSIONS);
if (!strstr(extensions, "GL_EXT_texture_format_BGRA8888")) {
- fprintf(stderr,
- "GL_EXT_texture_format_BGRA8888 not available\n");
+ WL_LOG_E("GL_EXT_texture_format_BGRA8888 not available");
return -1;
}
@@ -2121,7 +2121,7 @@ static int on_term_signal(int signal_number, void *data)
{
struct wl_display *display = data;
- fprintf(stderr, "caught signal %d\n", signal_number);
+ WL_LOG_I("caught signal %d", signal_number);
wl_display_terminate(display);
return 1;
@@ -2134,12 +2134,12 @@ on_segv_signal(int s, siginfo_t *siginfo, void *context)
int i, count;
Dl_info info;
- fprintf(stderr, "caught segv\n");
+ WL_LOG_E("caught segv");
count = backtrace(buffer, ARRAY_LENGTH(buffer));
for (i = 0; i < count; i++) {
dladdr(buffer[i], &info);
- fprintf(stderr, " [%016lx] %s (%s)\n",
+ WL_LOG_E(" [%016lx] %s (%s)",
(long) buffer[i],
info.dli_sname ? info.dli_sname : "--",
info.dli_fname);
@@ -2162,15 +2162,13 @@ load_module(const char *name, const char *entrypoint, void **handle)
module = dlopen(path, RTLD_LAZY);
if (!module) {
- fprintf(stderr,
- "failed to load module: %s\n", dlerror());
+ WL_LOG_E("failed to load module: %s", dlerror());
return NULL;
}
init = dlsym(module, entrypoint);
if (!init) {
- fprintf(stderr,
- "failed to lookup init function: %s\n", dlerror());
+ WL_LOG_E("failed to lookup init function: %s", dlerror());
return NULL;
}
@@ -2237,6 +2235,7 @@ int main(int argc, char *argv[])
}
wl_log_init();
+ WL_LOG_I("Starting Weston Compositor.");
display = wl_display_create();
loop = wl_display_get_event_loop(display);
@@ -2280,7 +2279,7 @@ int main(int argc, char *argv[])
ec = backend_init(display, backend_options);
if (ec == NULL) {
- fprintf(stderr, "failed to create compositor\n");
+ WL_LOG_E("failed to create compositor");
exit(EXIT_FAILURE);
}
@@ -2294,7 +2293,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
if (wl_display_add_socket(display, option_socket_name)) {
- fprintf(stderr, "failed to add socket: %m\n");
+ WL_LOG_E("failed to add socket: %m");
exit(EXIT_FAILURE);
}
diff --git a/src/evdev.c b/src/evdev.c
index f489ede..4936fbd 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -28,6 +28,7 @@
#include <fcntl.h>
#include "compositor.h"
+#include "log.h"
#include "evdev.h"
struct evdev_input {
@@ -547,13 +548,12 @@ evdev_add_devices(struct udev *udev, struct weston_input_device *input_base)
udev_enumerate_unref(e);
if (wl_list_empty(&input->devices_list)) {
- fprintf(stderr,
- "warning: no input devices on entering Weston. "
+ WL_LOG_W("no input devices on entering Weston. "
"Possible causes:\n"
"\t- no permissions to read /dev/input/event*\n"
"\t- seats misconfigured "
"(Weston backend option 'seat', "
- "udev device property ID_SEAT)\n");
+ "udev device property ID_SEAT)");
}
}
@@ -592,7 +592,7 @@ evdev_config_udev_monitor(struct udev *udev, struct evdev_input *master)
master->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
if (!master->udev_monitor) {
- fprintf(stderr, "udev: failed to create the udev monitor\n");
+ WL_LOG_E("udev: failed to create the udev monitor");
return 0;
}
@@ -600,7 +600,7 @@ evdev_config_udev_monitor(struct udev *udev, struct evdev_input *master)
"input", NULL);
if (udev_monitor_enable_receiving(master->udev_monitor)) {
- fprintf(stderr, "udev: failed to bind the udev monitor\n");
+ WL_LOG_E("udev: failed to bind the udev monitor");
return 0;
}
diff --git a/src/shell.c b/src/shell.c
index 66c4f01..697b025 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -33,6 +33,7 @@
#include <wayland-server.h>
#include "compositor.h"
+#include "log.h"
#include "desktop-shell-server-protocol.h"
#include "../shared/config-parser.h"
@@ -798,7 +799,7 @@ handle_lock_surface_destroy(struct wl_listener *listener,
struct wl_shell *shell =
container_of(listener, struct wl_shell, lock_surface_listener);
- fprintf(stderr, "lock surface gone\n");
+ WL_LOG_D("lock surface gone");
shell->lock_surface = NULL;
}
@@ -1188,9 +1189,7 @@ lock(struct weston_shell *base)
* receive input events while we are locked. */
if (!wl_list_empty(&shell->hidden_surface_list)) {
- fprintf(stderr,
- "%s: Assertion failed: hidden_surface_list is not empty.\n",
- __func__);
+ WL_LOG_E("Assertion failed: hidden_surface_list is not empty.");
}
wl_list_for_each_safe(cur, tmp, surface_list, link) {
@@ -1436,11 +1435,11 @@ desktop_shell_sigchld(struct weston_process *process, int status)
shell->child.deathcount++;
if (shell->child.deathcount > 5) {
- fprintf(stderr, "weston-desktop-shell died, giving up.\n");
+ WL_LOG_W("weston-desktop-shell died, giving up.");
return;
}
- fprintf(stderr, "weston-desktop-shell died, respawning...\n");
+ WL_LOG_W("weston-desktop-shell died, respawning...");
launch_desktop_shell_process(shell);
}
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index 48784f6..7e0c530 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -28,6 +28,7 @@
#include <linux/input.h>
#include "compositor.h"
+#include "log.h"
#include "tablet-shell-server-protocol.h"
/*
@@ -86,8 +87,7 @@ tablet_shell_sigchld(struct weston_process *process, int status)
shell->process.pid = 0;
- fprintf(stderr,
- "weston-tablet-shell crashed, exit code %d\n", status);
+ WL_LOG_E("weston-tablet-shell crashed, exit code %d", status);
}
static void
@@ -97,7 +97,7 @@ tablet_shell_set_state(struct tablet_shell *shell, int state)
"STARTING", "LOCKED", "HOME", "SWITCHER", "TASK"
};
- fprintf(stderr, "switching to state %s (from %s)\n",
+ WL_LOG_I("switching to state %s (from %s)",
states[state], states[shell->state]);
shell->previous_state = shell->state;
shell->state = state;
@@ -250,7 +250,7 @@ tablet_shell_switch_to(struct tablet_shell *shell,
minimize_zoom_done, shell);
}
} else {
- fprintf(stderr, "switch to %p\n", surface);
+ WL_LOG_D("switch to %p", surface);
weston_surface_activate(surface, device,
weston_compositor_get_time());
tablet_shell_set_state(shell, STATE_TASK);
@@ -345,7 +345,7 @@ tablet_shell_create_client(struct wl_client *client,
tablet_client->surface = NULL;
shell->current_client = tablet_client;
- fprintf(stderr, "created client %p, id %d, name %s, fd %d\n",
+ WL_LOG_D("created client %p, id %d, name %s, fd %d",
tablet_client->client, id, name, fd);
}
diff --git a/src/tty.c b/src/tty.c
index 249f5bb..feb1958 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -33,6 +33,7 @@
#include <sys/ioctl.h>
#include "compositor.h"
+#include "log.h"
struct tty {
struct weston_compositor *compositor;
@@ -85,19 +86,19 @@ try_open_vt(struct tty *tty)
tty0 = open("/dev/tty0", O_WRONLY | O_CLOEXEC);
if (tty0 < 0) {
- fprintf(stderr, "could not open tty0: %m\n");
+ WL_LOG_E("could not open tty0: %m");
return -1;
}
if (ioctl(tty0, VT_OPENQRY, &tty->vt) < 0 || tty->vt == -1) {
- fprintf(stderr, "could not open tty0: %m\n");
+ WL_LOG_E("could not open tty0: %m");
close(tty0);
return -1;
}
close(tty0);
snprintf(filename, sizeof filename, "/dev/tty%d", tty->vt);
- fprintf(stderr, "compositor: using new vt %s\n", filename);
+ WL_LOG_I("compositor: using new vt %s", filename);
fd = open(filename, O_RDWR | O_NOCTTY | O_CLOEXEC);
if (fd < 0)
return fd;
@@ -109,7 +110,7 @@ try_open_vt(struct tty *tty)
if (ioctl(fd, VT_ACTIVATE, tty->vt) < 0 ||
ioctl(fd, VT_WAITACTIVE, tty->vt) < 0) {
- fprintf(stderr, "failed to swtich to new vt\n");
+ WL_LOG_E("failed to swtich to new vt");
close(fd);
return -1;
}
@@ -138,7 +139,7 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
tty->vt_func = vt_func;
if (tty_nr > 0) {
snprintf(filename, sizeof filename, "/dev/tty%d", tty_nr);
- fprintf(stderr, "compositor: using %s\n", filename);
+ WL_LOG_I("compositor: using %s", filename);
tty->fd = open(filename, O_RDWR | O_NOCTTY | O_CLOEXEC);
} else if (fstat(tty->fd, &buf) == 0 &&
major(buf.st_rdev) == TTY_MAJOR &&
@@ -151,12 +152,12 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
}
if (tty->fd <= 0) {
- fprintf(stderr, "failed to open tty: %m\n");
+ WL_LOG_E("failed to open tty: %m");
return NULL;
}
if (tcgetattr(tty->fd, &tty->terminal_attributes) < 0) {
- fprintf(stderr, "could not get terminal attributes: %m\n");
+ WL_LOG_E("could not get terminal attributes: %m");
return NULL;
}
@@ -168,7 +169,7 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
raw_attributes.c_oflag |= OPOST | OCRNL;
if (tcsetattr(tty->fd, TCSANOW, &raw_attributes) < 0)
- fprintf(stderr, "could not put terminal into raw mode: %m\n");
+ WL_LOG_W("could not put terminal into raw mode: %m");
loop = wl_display_get_event_loop(compositor->wl_display);
tty->input_source =
@@ -177,7 +178,7 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
ret = ioctl(tty->fd, KDSETMODE, KD_GRAPHICS);
if (ret) {
- fprintf(stderr, "failed to set KD_GRAPHICS mode on tty: %m\n");
+ WL_LOG_E("failed to set KD_GRAPHICS mode on tty: %m");
return NULL;
}
@@ -186,7 +187,7 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
mode.relsig = SIGUSR1;
mode.acqsig = SIGUSR1;
if (ioctl(tty->fd, VT_SETMODE, &mode) < 0) {
- fprintf(stderr, "failed to take control of vt handling\n");
+ WL_LOG_E("failed to take control of vt handling");
return NULL;
}
@@ -205,16 +206,14 @@ tty_destroy(struct tty *tty)
return;
if (ioctl(tty->fd, KDSETMODE, KD_TEXT))
- fprintf(stderr,
- "failed to set KD_TEXT mode on tty: %m\n");
+ WL_LOG_W("failed to set KD_TEXT mode on tty: %m");
if (tcsetattr(tty->fd, TCSANOW, &tty->terminal_attributes) < 0)
- fprintf(stderr,
- "could not restore terminal to canonical mode\n");
+ WL_LOG_W("could not restore terminal to canonical mode");
mode.mode = VT_AUTO;
if (ioctl(tty->fd, VT_SETMODE, &mode) < 0)
- fprintf(stderr, "could not reset vt handling\n");
+ WL_LOG_W("could not reset vt handling");
if (tty->has_vt && tty->vt != tty->starting_vt) {
ioctl(tty->fd, VT_ACTIVATE, tty->starting_vt);
diff --git a/src/xserver-launcher.c b/src/xserver-launcher.c
index b85b813..444cffa 100644
--- a/src/xserver-launcher.c
+++ b/src/xserver-launcher.c
@@ -38,6 +38,7 @@
#include <wayland-server.h>
#include "compositor.h"
+#include "log.h"
#include "xserver-server-protocol.h"
#include "hash.h"
@@ -356,11 +357,11 @@ weston_wm_write_property(int fd, uint32_t mask, void *data)
free(wm->property_reply);
wl_event_source_remove(wm->property_source);
close(fd);
- fprintf(stderr, "write error to target fd: %m\n");
+ WL_LOG_E("write error to target fd: %m\n");
return 1;
}
- fprintf(stderr, "wrote %d (chunk size %d) of %d bytes\n",
+ WL_LOG_I("wrote %d (chunk size %d) of %d bytes\n",
wm->property_start + len,
len, xcb_get_property_value_length(wm->property_reply));
@@ -374,7 +375,7 @@ weston_wm_write_property(int fd, uint32_t mask, void *data)
wm->selection_window,
wm->atom.wl_selection);
} else {
- fprintf(stderr, "transfer complete\n");
+ WL_LOG_I("transfer complete\n");
close(fd);
}
}
@@ -444,7 +445,7 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
wm);
wm->property_reply = reply;
} else {
- fprintf(stderr, "transfer complete\n");
+ WL_LOG_I("transfer complete\n");
close(wm->data_source_fd);
free(reply);
}
@@ -463,13 +464,13 @@ weston_wm_set_selection(struct wl_selection_listener *listener,
if (source->offer_interface == &data_offer_interface)
return;
- fprintf(stderr, "set selection\n");
+ WL_LOG_I("set selection\n");
p = source->mime_types.data;
end = (const char **)
((char *) source->mime_types.data + source->mime_types.size);
while (p < end) {
- fprintf(stderr, " %s\n", *p);
+ WL_LOG_D(" %s\n", *p);
if (strcmp(*p, "text/plain") == 0 ||
strcmp(*p, "text/plain;charset=utf-8") == 0)
has_text_plain = 1;
@@ -497,7 +498,7 @@ weston_wm_handle_configure_request(struct weston_wm *wm, xcb_generic_event_t *ev
uint32_t values[16];
int i = 0;
- fprintf(stderr, "XCB_CONFIGURE_REQUEST (window %d) %d,%d @ %dx%d\n",
+ WL_LOG_D("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);
@@ -528,7 +529,7 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, xcb_generic_event_t *eve
xcb_configure_notify_event_t *configure_notify =
(xcb_configure_notify_event_t *) event;
- fprintf(stderr, "XCB_CONFIGURE_NOTIFY (window %d) %d,%d @ %dx%d\n",
+ WL_LOG_D("XCB_CONFIGURE_NOTIFY (window %d) %d,%d @ %dx%d\n",
configure_notify->window,
configure_notify->x, configure_notify->y,
configure_notify->width, configure_notify->height);
@@ -576,7 +577,7 @@ weston_wm_handle_map_request(struct weston_wm *wm, xcb_generic_event_t *event)
xcb_map_request_event_t *map_request =
(xcb_map_request_event_t *) event;
- fprintf(stderr, "XCB_MAP_REQUEST (window %d)\n", map_request->window);
+ WL_LOG_D("XCB_MAP_REQUEST (window %d)\n", map_request->window);
xcb_map_window(wm->conn, map_request->window);
}
@@ -611,7 +612,7 @@ weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
xcb_atom_t *atom;
int i;
- fprintf(stderr, "XCB_MAP_NOTIFY (window %d)\n", map_notify->window);
+ WL_LOG_D("XCB_MAP_NOTIFY (window %d)\n", map_notify->window);
dump_window_properties(wm, map_notify->window);
@@ -662,7 +663,7 @@ weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
free(reply);
}
- fprintf(stderr, "window %d: name %s, class %s, transient_for %d\n",
+ WL_LOG_D("window %d: name %s, class %s, transient_for %d\n",
window->id, window->name, window->class,
window->transient_for ? window->transient_for->id : 0);
weston_wm_activate(wm, window, XCB_TIME_CURRENT_TIME);
@@ -762,20 +763,20 @@ weston_wm_read_data_source(int fd, uint32_t mask, void *data)
len = read(fd, p, available);
if (len == -1) {
- fprintf(stderr, "read error from data source: %m\n");
+ WL_LOG_E("read error from data source: %m\n");
weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
wl_event_source_remove(wm->property_source);
close(fd);
wl_array_release(&wm->source_data);
}
- fprintf(stderr, "read %d (available %d, mask 0x%x) bytes: \"%.*s\"\n",
+ WL_LOG_I("read %d (available %d, mask 0x%x) bytes: \"%.*s\"\n",
len, available, mask, len, (char *) p);
wm->source_data.size = current + len;
if (wm->source_data.size >= incr_chunk_size) {
if (!wm->incr) {
- fprintf(stderr, "got %d bytes, starting incr\n",
+ WL_LOG_I("got %d bytes, starting incr\n",
wm->source_data.size);
wm->incr = 1;
xcb_change_property(wm->conn,
@@ -790,19 +791,19 @@ weston_wm_read_data_source(int fd, uint32_t mask, void *data)
wl_event_source_remove(wm->property_source);
weston_wm_send_selection_notify(wm, wm->selection_request.property);
} else if (wm->selection_property_set) {
- fprintf(stderr, "got %d bytes, waiting for "
+ WL_LOG_I("got %d bytes, waiting for "
"property delete\n", wm->source_data.size);
wm->flush_property_on_delete = 1;
wl_event_source_remove(wm->property_source);
} else {
- fprintf(stderr, "got %d bytes, "
+ WL_LOG_I("got %d bytes, "
"property deleted, seting new property\n",
wm->source_data.size);
weston_wm_flush_source_data(wm);
}
} else if (len == 0 && !wm->incr) {
- fprintf(stderr, "non-incr transfer complete\n");
+ WL_LOG_I("non-incr transfer complete\n");
/* Non-incr transfer all done. */
weston_wm_flush_source_data(wm);
weston_wm_send_selection_notify(wm, wm->selection_request.property);
@@ -812,14 +813,14 @@ weston_wm_read_data_source(int fd, uint32_t mask, void *data)
wl_array_release(&wm->source_data);
wm->selection_request.requestor = XCB_NONE;
} else if (len == 0 && wm->incr) {
- fprintf(stderr, "incr transfer complete\n");
+ WL_LOG_I("incr transfer complete\n");
wm->flush_property_on_delete = 1;
if (wm->selection_property_set) {
- fprintf(stderr, "got %d bytes, waiting for "
+ WL_LOG_I("got %d bytes, waiting for "
"property delete\n", wm->source_data.size);
} else {
- fprintf(stderr, "got %d bytes, "
+ WL_LOG_I("got %d bytes, "
"property deleted, seting new property\n",
wm->source_data.size);
weston_wm_flush_source_data(wm);
@@ -829,7 +830,7 @@ weston_wm_read_data_source(int fd, uint32_t mask, void *data)
wm->data_source_fd = -1;
close(fd);
} else {
- fprintf(stderr, "nothing happened, buffered the bytes\n");
+ WL_LOG_I("nothing happened, buffered the bytes\n");
}
return 1;
@@ -842,7 +843,7 @@ weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_ty
int p[2];
if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1) {
- fprintf(stderr, "pipe2 failed: %m\n");
+ WL_LOG_E("pipe2 failed: %m\n");
weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
return;
}
@@ -864,12 +865,12 @@ weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_ty
static void
weston_wm_send_incr_chunk(struct weston_wm *wm)
{
- fprintf(stderr, "property deleted\n");
+ WL_LOG_I("property deleted\n");
int length;
wm->selection_property_set = 0;
if (wm->flush_property_on_delete) {
- fprintf(stderr, "setting new property, %d bytes\n",
+ WL_LOG_I("setting new property, %d bytes\n",
wm->source_data.size);
wm->flush_property_on_delete = 0;
length = weston_wm_flush_source_data(wm);
@@ -901,11 +902,11 @@ weston_wm_handle_selection_request(struct weston_wm *wm,
xcb_selection_request_event_t *selection_request =
(xcb_selection_request_event_t *) event;
- fprintf(stderr, "selection request, %s, ",
+ WL_LOG_I("selection request, %s, ",
get_atom_name(wm->conn, selection_request->selection));
- fprintf(stderr, "target %s, ",
+ WL_LOG_I("target %s, ",
get_atom_name(wm->conn, selection_request->target));
- fprintf(stderr, "property %s\n",
+ WL_LOG_I("property %s\n",
get_atom_name(wm->conn, selection_request->property));
wm->selection_request = *selection_request;
@@ -921,7 +922,7 @@ weston_wm_handle_selection_request(struct weston_wm *wm,
weston_wm_send_data(wm, wm->atom.utf8_string,
"text/plain;charset=utf-8");
} else {
- fprintf(stderr, "can only handle UTF8_STRING targets...\n");
+ WL_LOG_W("can only handle UTF8_STRING targets...\n");
weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
}
}
@@ -943,23 +944,23 @@ weston_wm_handle_property_notify(struct weston_wm *wm, xcb_generic_event_t *even
wm->incr)
weston_wm_send_incr_chunk(wm);
} else if (property_notify->atom == XCB_ATOM_WM_CLASS) {
- fprintf(stderr, "wm_class changed\n");
+ WL_LOG_I("wm_class changed\n");
} else if (property_notify->atom == XCB_ATOM_WM_TRANSIENT_FOR) {
- fprintf(stderr, "wm_transient_for changed\n");
+ WL_LOG_I("wm_transient_for changed\n");
} else if (property_notify->atom == wm->atom.wm_protocols) {
- fprintf(stderr, "wm_protocols changed\n");
+ WL_LOG_I("wm_protocols changed\n");
} else if (property_notify->atom == wm->atom.net_wm_name) {
- fprintf(stderr, "_net_wm_name changed\n");
+ WL_LOG_I("_net_wm_name changed\n");
} else if (property_notify->atom == wm->atom.net_wm_user_time) {
- fprintf(stderr, "_net_wm_user_time changed\n");
+ WL_LOG_I("_net_wm_user_time changed\n");
} else if (property_notify->atom == wm->atom.net_wm_icon_name) {
- fprintf(stderr, "_net_wm_icon_name changed\n");
+ WL_LOG_I("_net_wm_icon_name changed\n");
} else if (property_notify->atom == XCB_ATOM_WM_NAME) {
- fprintf(stderr, "wm_name changed\n");
+ WL_LOG_I("wm_name changed\n");
} else if (property_notify->atom == XCB_ATOM_WM_ICON_NAME) {
- fprintf(stderr, "wm_icon_name changed\n");
+ WL_LOG_I("wm_icon_name changed\n");
} else {
- fprintf(stderr, "XCB_PROPERTY_NOTIFY: "
+ WL_LOG_I("XCB_PROPERTY_NOTIFY: "
"unhandled property change: %s\n",
get_atom_name(wm->conn, property_notify->atom));
}
@@ -973,12 +974,12 @@ weston_wm_handle_create_notify(struct weston_wm *wm, xcb_generic_event_t *event)
struct weston_wm_window *window;
uint32_t values[1];
- fprintf(stderr, "XCB_CREATE_NOTIFY (window %d)\n",
+ WL_LOG_I("XCB_CREATE_NOTIFY (window %d)\n",
create_notify->window);
window = malloc(sizeof *window);
if (window == NULL) {
- fprintf(stderr, "failed to allocate window\n");
+ WL_LOG_W("failed to allocate window\n");
return;
}
@@ -998,17 +999,17 @@ 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;
- fprintf(stderr, "XCB_DESTROY_NOTIFY, win %d\n",
+ WL_LOG_I("XCB_DESTROY_NOTIFY, win %d\n",
destroy_notify->window);
window = hash_table_lookup(wm->window_hash, destroy_notify->window);
if (window == NULL) {
- fprintf(stderr, "destroy notify for unknow window %d\n",
+ WL_LOG_I("destroy notify for unknow window %d\n",
destroy_notify->window);
return;
}
- fprintf(stderr, "destroy window %p\n", window);
+ WL_LOG_I("destroy window %p\n", window);
hash_table_remove(wm->window_hash, window->id);
if (window->surface)
wl_list_remove(&window->surface_destroy_listener.link);
@@ -1046,7 +1047,7 @@ weston_wm_handle_xfixes_selection_notify(struct weston_wm *wm,
* answer TIMESTAMP conversion requests correctly. */
if (xfixes_selection_notify->owner == wm->selection_window) {
wm->selection_timestamp = xfixes_selection_notify->timestamp;
- fprintf(stderr, "our window, skipping\n");
+ WL_LOG_D("our window, skipping\n");
return;
}
@@ -1067,7 +1068,7 @@ weston_wm_handle_client_message(struct weston_wm *wm,
xcb_client_message_event_t *client_message =
(xcb_client_message_event_t *) event;
- fprintf(stderr, "got client message, type: %s\n",
+ WL_LOG_D("got client message, type: %s\n",
get_atom_name(wm->conn, client_message->type));
}
@@ -1090,7 +1091,7 @@ weston_wm_handle_event(int fd, uint32_t mask, void *data)
weston_wm_handle_map_notify(wm, event);
break;
case XCB_UNMAP_NOTIFY:
- fprintf(stderr, "XCB_UNMAP_NOTIFY\n");
+ WL_LOG_D("XCB_UNMAP_NOTIFY\n");
break;
case XCB_CONFIGURE_REQUEST:
weston_wm_handle_configure_request(wm, event);
@@ -1102,7 +1103,7 @@ weston_wm_handle_event(int fd, uint32_t mask, void *data)
weston_wm_handle_destroy_notify(wm, event);
break;
case XCB_MAPPING_NOTIFY:
- fprintf(stderr, "XCB_MAPPING_NOTIFY\n");
+ WL_LOG_D("XCB_MAPPING_NOTIFY\n");
break;
case XCB_PROPERTY_NOTIFY:
weston_wm_handle_property_notify(wm, event);
@@ -1191,7 +1192,7 @@ wxs_wm_get_resources(struct weston_wm *wm)
wm->xfixes = xcb_get_extension_data(wm->conn, &xcb_xfixes_id);
if (!wm->xfixes || !wm->xfixes->present)
- fprintf(stderr, "xfixes not available\n");
+ WL_LOG_I("xfixes not available\n");
xfixes_cookie = xcb_xfixes_query_version(wm->conn,
XCB_XFIXES_MAJOR_VERSION,
@@ -1271,7 +1272,7 @@ weston_wm_create(struct weston_xserver *wxs)
}
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
- fprintf(stderr, "socketpair failed\n");
+ WL_LOG_W("socketpair failed\n");
hash_table_destroy(wm->window_hash);
free(wm);
return NULL;
@@ -1284,7 +1285,7 @@ weston_wm_create(struct weston_xserver *wxs)
/* xcb_connect_to_fd takes ownership of the fd. */
wm->conn = xcb_connect_to_fd(sv[0], NULL);
if (xcb_connection_has_error(wm->conn)) {
- fprintf(stderr, "xcb_connect_to_fd failed\n");
+ WL_LOG_W("xcb_connect_to_fd failed\n");
close(sv[0]);
hash_table_destroy(wm->window_hash);
free(wm);
@@ -1352,7 +1353,7 @@ weston_wm_create(struct weston_xserver *wxs)
wl_list_insert(&device->selection_listener_list,
&wm->selection_listener.link);
- fprintf(stderr, "created wm\n");
+ WL_LOG_W("created wm\n");
return wm;
}
@@ -1376,7 +1377,7 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
int sv[2], client_fd;
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
- fprintf(stderr, "socketpair failed\n");
+ WL_LOG_W("socketpair failed\n");
return 1;
}
@@ -1403,11 +1404,11 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
"-nolisten", "all",
"-terminate",
NULL) < 0)
- fprintf(stderr, "exec failed: %m\n");
+ WL_LOG_W("exec failed: %m\n");
exit(-1);
default:
- fprintf(stderr, "forked X server, pid %d\n", mxs->process.pid);
+ WL_LOG_I("forked X server, pid %d\n", mxs->process.pid);
close(sv[1]);
mxs->client = wl_client_create(mxs->wl_display, sv[0]);
@@ -1419,7 +1420,7 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
break;
case -1:
- fprintf(stderr, "failed to fork\n");
+ WL_LOG_E("failed to fork\n");
break;
}
@@ -1467,14 +1468,14 @@ weston_xserver_cleanup(struct weston_process *process, int status)
weston_xserver_handle_event, mxs);
if (mxs->wm) {
- fprintf(stderr, "xserver exited, code %d\n", status);
+ WL_LOG_I("xserver exited, code %d\n", status);
weston_wm_destroy(mxs->wm);
mxs->wm = NULL;
} else {
/* If the X server crashes before it binds to the
* xserver interface, shut down and don't try
* again. */
- fprintf(stderr, "xserver crashing too fast: %d\n", status);
+ WL_LOG_W("xserver crashing too fast: %d\n", status);
weston_xserver_shutdown(mxs);
}
}
@@ -1487,7 +1488,7 @@ surface_destroy(struct wl_listener *listener,
container_of(listener,
struct weston_wm_window, surface_destroy_listener);
- fprintf(stderr, "surface for xid %d destroyed\n", window->id);
+ WL_LOG_D("surface for xid %d destroyed\n", window->id);
}
static struct weston_wm_window *
@@ -1520,11 +1521,11 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
window = hash_table_lookup(wm->window_hash, id);
if (window == NULL) {
- fprintf(stderr, "set_window_id for unknown window %d\n", id);
+ WL_LOG_D("set_window_id for unknown window %d\n", id);
return;
}
- fprintf(stderr, "set_window_id %d for surface %p\n", id, surface);
+ WL_LOG_D("set_window_id %d for surface %p\n", id, surface);
window->surface = (struct weston_surface *) surface;
window->surface_destroy_listener.func = surface_destroy;
@@ -1553,7 +1554,7 @@ bind_xserver(struct wl_client *client,
wxs->wm = weston_wm_create(wxs);
if (wxs->wm == NULL) {
- fprintf(stderr, "failed to create wm\n");
+ WL_LOG_E("failed to create wm\n");
}
wl_resource_post_event(wxs->resource,
@@ -1579,7 +1580,7 @@ bind_to_abstract_socket(int display)
"%c/tmp/.X11-unix/X%d", 0, display);
size = offsetof(struct sockaddr_un, sun_path) + name_size;
if (bind(fd, (struct sockaddr *) &addr, size) < 0) {
- fprintf(stderr, "failed to bind to @%s: %s\n",
+ WL_LOG_E("failed to bind to @%s: %s\n",
addr.sun_path + 1, strerror(errno));
close(fd);
return -1;
@@ -1610,7 +1611,7 @@ bind_to_unix_socket(int display)
size = offsetof(struct sockaddr_un, sun_path) + name_size;
unlink(addr.sun_path);
if (bind(fd, (struct sockaddr *) &addr, size) < 0) {
- fprintf(stderr, "failed to bind to %s (%s)\n",
+ WL_LOG_E("failed to bind to %s (%s)\n",
addr.sun_path, strerror(errno));
close(fd);
return -1;
@@ -1637,7 +1638,7 @@ create_lockfile(int display, char *lockfile, size_t lsize)
if (fd < 0 && errno == EEXIST) {
fd = open(lockfile, O_CLOEXEC, O_RDONLY);
if (fd < 0 || read(fd, pid, 11) != 11) {
- fprintf(stderr, "can't read lock file %s: %s\n",
+ WL_LOG_E("can't read lock file %s: %s\n",
lockfile, strerror(errno));
errno = EEXIST;
return -1;
@@ -1645,7 +1646,7 @@ create_lockfile(int display, char *lockfile, size_t lsize)
other = strtol(pid, &end, 0);
if (end != pid + 10) {
- fprintf(stderr, "can't parse lock file %s\n",
+ WL_LOG_E("can't parse lock file %s\n",
lockfile);
errno = EEXIST;
return -1;
@@ -1653,8 +1654,7 @@ create_lockfile(int display, char *lockfile, size_t lsize)
if (kill(other, 0) < 0 && errno == ESRCH) {
/* stale lock file; unlink and try again */
- fprintf(stderr,
- "unlinking stale lock file %s\n", lockfile);
+ WL_LOG_I("unlinking stale lock file %s\n", lockfile);
unlink(lockfile);
errno = EAGAIN;
return -1;
@@ -1663,7 +1663,7 @@ create_lockfile(int display, char *lockfile, size_t lsize)
errno = EEXIST;
return -1;
} else if (fd < 0) {
- fprintf(stderr, "failed to create lock file %s: %s\n",
+ WL_LOG_E("failed to create lock file %s: %s\n",
lockfile, strerror(errno));
return -1;
}
@@ -1727,7 +1727,7 @@ weston_xserver_init(struct weston_compositor *compositor)
}
snprintf(display_name, sizeof display_name, ":%d", mxs->display);
- fprintf(stderr, "xserver listening on display %s\n", display_name);
+ WL_LOG_I("xserver listening on display %s\n", display_name);
setenv("DISPLAY", display_name, 1);
mxs->loop = wl_display_get_event_loop(display);
--
1.7.9
More information about the wayland-devel
mailing list