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.
This commit is contained in:
Isaac Freund
2025-09-02 09:46:46 +02:00
parent f0c7f57d36
commit c18ed4aae1

View File

@ -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