diff options
author | 2021-06-06 14:12:52 -0700 | |
---|---|---|
committer | 2021-06-06 14:12:52 -0700 | |
commit | 69627d8a47ca882841d462552f6d4a94611ab5e2 (patch) | |
tree | 5f7f782b2ade5660d26c275a0ef59379302afa24 /src | |
parent | f4245c90e8b3562b78b16678fb668df3a8f563f5 (diff) | |
download | bun-69627d8a47ca882841d462552f6d4a94611ab5e2.tar.gz bun-69627d8a47ca882841d462552f6d4a94611ab5e2.tar.zst bun-69627d8a47ca882841d462552f6d4a94611ab5e2.zip |
debug-only print
Former-commit-id: af7054c69bb4f1e5972c323da7a1f274481f97e9
Diffstat (limited to 'src')
-rw-r--r-- | src/global.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/global.zig b/src/global.zig index ecda14281..4cf3ccef0 100644 --- a/src/global.zig +++ b/src/global.zig @@ -121,6 +121,18 @@ pub const Output = struct { return print(fmt, args); } + pub const debug = if (isDebug) _debug else _noop; + + fn _noop(comptime fmt: string, args: anytype) void {} + + pub fn _debug(comptime fmt: string, args: anytype) void { + if (fmt[fmt.len - 1] != '\n') { + return print(fmt ++ "\n", args); + } + + return print(fmt, args); + } + pub fn print(comptime fmt: string, args: anytype) void { if (isWasm) { source.stream.seekTo(0) catch return; |