aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-07-10 12:58:47 -0700
committerAndrew Kelley <andrew@ziglang.org>2025-07-10 16:52:29 -0700
commit88e50b30c3c929761f2ae1a924b96f8bc7548b84 (patch)
tree4cca29e7651c8fec52c9cc76f5b27bf34f1de46b /lib/std/debug.zig
parentbd5745ddf2f5a5d42553b30241f0a44550f1672e (diff)
downloadzig-88e50b30c3c929761f2ae1a924b96f8bc7548b84.tar.gz
zig-88e50b30c3c929761f2ae1a924b96f8bc7548b84.zip
std.debug.print: provide a small buffer
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 5da650266e..0f64b7f951 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -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;
}