Skip to content

Commit d4ff1aa

Browse files
committed
Add std.debug.print for "printf debugging"
1 parent bd39ab2 commit d4ff1aa

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/std/debug.zig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,24 @@ var stderr_file_out_stream: File.OutStream = undefined;
5858
var stderr_stream: ?*File.OutStream = null;
5959
var stderr_mutex = std.Mutex.init();
6060

61-
/// Deprecated. Use `std.log` functions for logging.
61+
/// Deprecated. Use `std.log` functions for logging or `std.debug.print` for
62+
/// "printf debugging".
6263
pub fn warn(comptime fmt: []const u8, args: var) void {
6364
const held = stderr_mutex.acquire();
6465
defer held.release();
6566
const stderr = getStderrStream();
6667
nosuspend stderr.print(fmt, args) catch return;
6768
}
6869

70+
/// Print to stderr, silently returning on failure. Intended for use in
71+
/// "printf debugging." Use `std.log` functions for proper logging.
72+
pub fn print(comptime fmt: []const u8, args: var) void {
73+
const held = stderr_mutex.acquire();
74+
defer held.release();
75+
const stderr = getStderrStream();
76+
nosuspend stderr.print(fmt, args) catch return;
77+
}
78+
6979
pub fn getStderrStream() *File.OutStream {
7080
if (stderr_stream) |st| {
7181
return st;

0 commit comments

Comments
 (0)