Merge pull request #24394 from ziglang/fixes

buffering fixes
This commit is contained in:
Andrew Kelley
2025-07-11 10:56:24 +02:00
committed by GitHub
4 changed files with 29 additions and 14 deletions

View File

@@ -219,10 +219,14 @@ pub fn unlockStderrWriter() void {
std.Progress.unlockStderrWriter();
}
/// Print to stderr, unbuffered, and silently returning on failure. Intended
/// for use in "printf debugging". Use `std.log` functions for proper logging.
/// Print to stderr, silently returning on failure. Intended for use in "printf
/// debugging". Use `std.log` functions for proper logging.
///
/// Uses a 64-byte buffer for formatted printing which is flushed before this
/// function returns.
pub fn print(comptime fmt: []const u8, args: anytype) void {
const bw = lockStderrWriter(&.{});
var buffer: [64]u8 = undefined;
const bw = lockStderrWriter(&buffer);
defer unlockStderrWriter();
nosuspend bw.print(fmt, args) catch return;
}