authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-10 12:58:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-10 16:52:29-07:00
log88e50b30c3c929761f2ae1a924b96f8bc7548b84
tree4cca29e7651c8fec52c9cc76f5b27bf34f1de46b
parentbd5745ddf2f5a5d42553b30241f0a44550f1672e

std.debug.print: provide a small buffer


1 files changed, 7 insertions(+), 3 deletions(-)

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