zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit c29746aa553a72fe2ef2d414c1b616ee2a94eab4 (tree)
parent 85492f2b9146b91470ca613cf5208906fff12701
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun, 12 Jun 2022 00:57:59 -0700

add std.debug.Trace.format

This makes it show up in some useful places; for example in the
self-hosted compiler we already print it now with
--debug-compile-errors.

Diffstat:
Mlib/std/debug.zig | 17+++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/lib/std/debug.zig b/lib/std/debug.zig @@ -2023,5 +2023,22 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize }) catch return; } } + + pub fn format( + t: Trace, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) !void { + _ = fmt; + _ = options; + if (enabled) { + try writer.writeAll("\n"); + t.dump(); + try writer.writeAll("\n"); + } else { + return writer.writeAll("(value tracing disabled)"); + } + } }; }