| ... | @@ -219,10 +219,14 @@ pub fn unlockStderrWriter() void { | ... | @@ -219,10 +219,14 @@ pub fn unlockStderrWriter() void { |
| 219 | std.Progress.unlockStderrWriter(); | 219 | std.Progress.unlockStderrWriter(); |
| 220 | } | 220 | } |
| 221 | | 221 | |
| 222 | /// Print to stderr, unbuffered, and silently returning on failure. Intended | 222 | /// Print to stderr, silently returning on failure. Intended for use in "printf |
| 223 | /// for use in "printf debugging". Use `std.log` functions for proper logging. | 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. |
| 224 | pub fn print(comptime fmt: []const u8, args: anytype) void { | 227 | 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); |
| 226 | defer unlockStderrWriter(); | 230 | defer unlockStderrWriter(); |
| 227 | nosuspend bw.print(fmt, args) catch return; | 231 | nosuspend bw.print(fmt, args) catch return; |
| 228 | } | 232 | } |