Skip to content

Commit 88e50b3

Browse files
committed
std.debug.print: provide a small buffer
1 parent bd5745d commit 88e50b3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/std/debug.zig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
224227
pub 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
}

0 commit comments

Comments
 (0)