From c29746aa553a72fe2ef2d414c1b616ee2a94eab4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 12 Jun 2022 00:57:59 -0700 Subject: [PATCH] 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. --- lib/std/debug.zig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/std/debug.zig b/lib/std/debug.zig index ba45b16d1b..ba1f509e6c 100644 --- 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)"); + } + } }; }