From c18ed4aae18d6f7a20ab67c3a62abb31dc5de1c8 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 2 Sep 2025 09:46:46 +0200 Subject: [PATCH] river: fix logging to non-pipe Since the Zig 0.15 upgrade, if stderr is redirected to a file, river writes every log message to the beginning of the file, overwriting the previous message. This commit fixes that and also switches to the nicer new std.debug API for stderr logging. --- river/main.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/river/main.zig b/river/main.zig index 27a0bd5..d2f9481 100644 --- a/river/main.zig +++ b/river/main.zig @@ -188,8 +188,11 @@ pub fn logFn( const scope_prefix = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): "; - var stderr = fs.File.stderr().writer(&.{}); - stderr.interface.print(level.asText() ++ scope_prefix ++ format ++ "\n", args) catch {}; + var buffer: [256]u8 = undefined; + const stderr = std.debug.lockStderrWriter(&buffer); + defer std.debug.unlockStderrWriter(); + + stderr.print(level.asText() ++ scope_prefix ++ format ++ "\n", args) catch {}; } /// See wlroots_log_wrapper.c