aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-06-21 14:15:06 -0400
committerDrew DeVault <sir@cmpwn.com>2017-06-21 14:15:06 -0400
commitb93f00b92f20dcdc5360605649a142551bd837a9 (patch)
tree29c730fd1c1779ec1f97a3e0fd4bab7f23fa8e7c
parent3d71969b2a66a029df88e0c6bbcb8d388d57a13c (diff)
Utilize wlr_log in example logging
-rw-r--r--example/pointer.c7
-rw-r--r--example/shared.c15
-rw-r--r--util/log.c8
3 files changed, 16 insertions, 14 deletions
diff --git a/example/pointer.c b/example/pointer.c
index 6921d9b2..c2fb6ee5 100644
--- a/example/pointer.c
+++ b/example/pointer.c
@@ -5,6 +5,7 @@
#include <time.h>
#include <string.h>
#include <unistd.h>
+#include <math.h>
#include <wayland-server.h>
#include <wayland-server-protocol.h>
#include <xkbcommon/xkbcommon.h>
@@ -15,7 +16,7 @@
#include <wlr/backend.h>
#include <wlr/session.h>
#include <wlr/types/wlr_keyboard.h>
-#include <math.h>
+#include <wlr/util/log.h>
#include "shared.h"
#include "cat.h"
@@ -99,11 +100,11 @@ static void handle_output_add(struct output_state *ostate) {
int width = 16, height = 16;
if (!wlr_output_set_cursor(wlr_output, cat_tex.pixel_data,
width * 4, width, height)) {
- fprintf(stderr, "Failed to set cursor\n");
+ wlr_log(L_DEBUG, "Failed to set hardware cursor");
return;
}
if (!wlr_output_move_cursor(wlr_output, 0, 0)) {
- fprintf(stderr, "Failed to move cursor\n");
+ wlr_log(L_DEBUG, "Failed to move hardware cursor");
}
}
diff --git a/example/shared.c b/example/shared.c
index 8e7259d8..d9a6c1fd 100644
--- a/example/shared.c
+++ b/example/shared.c
@@ -11,6 +11,7 @@
#include <wlr/session.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_input_device.h>
+#include <wlr/util/log.h>
#include "shared.h"
static void keyboard_led_update(struct keyboard_state *kbstate) {
@@ -35,7 +36,7 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) {
char name[64];
int l = xkb_keysym_get_name(sym, name, sizeof(name));
if (l != -1 && l != sizeof(name)) {
- fprintf(stderr, "Key event: %s %s\n", name,
+ wlr_log(L_DEBUG, "Key event: %s %s", name,
key_state == WLR_KEY_PRESSED ? "pressed" : "released");
}
if (kbstate->compositor->keyboard_key_cb) {
@@ -65,19 +66,19 @@ static void keyboard_add(struct wlr_input_device *device, struct compositor_stat
rules.options = getenv("XKB_DEFAULT_OPTIONS");
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!context) {
- fprintf(stderr, "Failed to create XKB context\n");
+ wlr_log(L_ERROR, "Failed to create XKB context");
exit(1);
}
kbstate->keymap = xkb_map_new_from_names(
context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
if (!kbstate->keymap) {
- fprintf(stderr, "Failed to create XKB keymap\n");
+ wlr_log(L_ERROR, "Failed to create XKB keymap");
exit(1);
}
xkb_context_unref(context);
kbstate->xkb_state = xkb_state_new(kbstate->keymap);
if (!kbstate->xkb_state) {
- fprintf(stderr, "Failed to create XKB state\n");
+ wlr_log(L_ERROR, "Failed to create XKB state");
exit(1);
}
const char *led_names[3] = {
@@ -381,8 +382,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
static void output_add_notify(struct wl_listener *listener, void *data) {
struct wlr_output *output = data;
struct compositor_state *state = wl_container_of(listener, state, output_add);
- fprintf(stderr, "Output '%s' added\n", output->name);
- fprintf(stderr, "%s %s %"PRId32"mm x %"PRId32"mm\n", output->make, output->model,
+ wlr_log(L_DEBUG, "Output '%s' added", output->name);
+ wlr_log(L_DEBUG, "%s %s %"PRId32"mm x %"PRId32"mm", output->make, output->model,
output->phys_width, output->phys_height);
if (output->modes->length > 0) {
wlr_output_set_mode(output, output->modes->items[0]);
@@ -460,7 +461,7 @@ void compositor_init(struct compositor_state *state) {
clock_gettime(CLOCK_MONOTONIC, &state->last_frame);
if (!wlr_backend_init(state->backend)) {
- fprintf(stderr, "Failed to initialize backend\n");
+ wlr_log(L_ERROR, "Failed to initialize backend");
exit(1);
}
}
diff --git a/util/log.c b/util/log.c
index 760ef18a..57cf24f7 100644
--- a/util/log.c
+++ b/util/log.c
@@ -66,12 +66,12 @@ void _wlr_log(log_importance_t verbosity, const char *fmt, ...) {
// 'backend/wayland/backend.c'
const char *_strip_path(const char *filepath) {
static int srclen = strlen(WLR_SRC_DIR) + 1;
- if(*filepath == '.') {
- while(*filepath == '.' || *filepath == '/') {
+ if (strstr(filepath, WLR_SRC_DIR) == filepath) {
+ filepath += srclen;
+ } else if (*filepath == '.') {
+ while (*filepath == '.' || *filepath == '/') {
++filepath;
}
- } else {
- filepath += srclen;
}
return filepath;
}