diff options
| author | Caitlyn <caitlynrosestewart@gmail.com> | 2025-05-27 22:40:14 +0100 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2025-06-01 11:21:36 +0000 |
| commit | ecff0ee10c335f8f71251e67d615f4f719b6cbe1 (patch) | |
| tree | 8fdd87798b0c26893cd6dc232953144ce0affa41 /src/wayland-server.c | |
| parent | connection: fix segfault in wl_closure_invoke() (diff) | |
| download | wayland-ecff0ee10c335f8f71251e67d615f4f719b6cbe1.tar wayland-ecff0ee10c335f8f71251e67d615f4f719b6cbe1.tar.gz wayland-ecff0ee10c335f8f71251e67d615f4f719b6cbe1.tar.bz2 wayland-ecff0ee10c335f8f71251e67d615f4f719b6cbe1.tar.lz wayland-ecff0ee10c335f8f71251e67d615f4f719b6cbe1.tar.xz wayland-ecff0ee10c335f8f71251e67d615f4f719b6cbe1.tar.zst wayland-ecff0ee10c335f8f71251e67d615f4f719b6cbe1.zip | |
debug: Colorize output for easier reading
Signed-off-by: Caitlyn <caitlynrosestewart@gmail.com>
Diffstat (limited to 'src/wayland-server.c')
| -rw-r--r-- | src/wayland-server.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c index a538519..96dd417 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -149,6 +149,7 @@ struct wl_protocol_logger { }; static int debug_server = 0; +static int debug_color = 0; static void log_closure(struct wl_resource *resource, @@ -160,7 +161,7 @@ log_closure(struct wl_resource *resource, struct wl_protocol_logger_message message; if (debug_server) - wl_closure_print(closure, object, send, false, NULL, NULL); + wl_closure_print(closure, object, send, false, NULL, NULL, debug_color); if (!wl_list_empty(&display->protocol_loggers)) { message.resource = resource; @@ -1168,10 +1169,23 @@ wl_display_create(void) { struct wl_display *display; const char *debug; + const char *no_color; + const char *force_color; + no_color = getenv("NO_COLOR"); + force_color = getenv("FORCE_COLOR"); debug = getenv("WAYLAND_DEBUG"); - if (debug && (strstr(debug, "server") || strstr(debug, "1"))) + if (debug && (strstr(debug, "server") || strstr(debug, "1"))) { debug_server = 1; + if (isatty(fileno(stderr))) + debug_color = 1; + } + + if (force_color && force_color[0] != '\0') + debug_color = 1; + + if (no_color && no_color[0] != '\0') + debug_color = 0; display = zalloc(sizeof *display); if (display == NULL) |
