authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-18 13:46:52-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-19 19:10:12-07:00
log8df1b91d17dcc81a15458d5c73351bca3106922a
tree44cf191e20c1342992c2f5cca65f814ae201766d
parente5d21e10bc6e652a72cf22ad1b1cf8ba8692abbf

Autodoc: clean up debug printing

use std.log.scoped

1 files changed, 20 insertions(+), 21 deletions(-)

src/Autodoc.zig+20-21
...@@ -7,6 +7,7 @@ const File = Module.File;...@@ -7,6 +7,7 @@ const File = Module.File;
7const Package = @import("Package.zig");7const Package = @import("Package.zig");
8const Zir = @import("Zir.zig");8const Zir = @import("Zir.zig");
9const Ref = Zir.Inst.Ref;9const Ref = Zir.Inst.Ref;
10const log = std.log.scoped(.autodoc);
1011
11module: *Module,12module: *Module,
12doc_location: Compilation.EmitLoc,13doc_location: Compilation.EmitLoc,
...@@ -62,7 +63,7 @@ pub fn deinit(_: *Autodoc) void {...@@ -62,7 +63,7 @@ pub fn deinit(_: *Autodoc) void {
62pub fn generateZirData(self: *Autodoc) !void {63pub fn generateZirData(self: *Autodoc) !void {
63 if (self.doc_location.directory) |dir| {64 if (self.doc_location.directory) |dir| {
64 if (dir.path) |path| {65 if (dir.path) |path| {
65 std.debug.print("path: {s}\n", .{path});66 log.debug("path: {s}", .{path});
66 }67 }
67 }68 }
6869
...@@ -1700,12 +1701,12 @@ fn walkInstruction(...@@ -1700,12 +1701,12 @@ fn walkInstruction(
1700 // const ast_line = self.ast_nodes.items[ast_index - 1];1701 // const ast_line = self.ast_nodes.items[ast_index - 1];
17011702
1702 // const sep = "=" ** 200;1703 // const sep = "=" ** 200;
1703 // std.debug.print("{s}\n", .{sep});1704 // log.debug("{s}", .{sep});
1704 // std.debug.print("SWITCH BLOCK\n", .{});1705 // log.debug("SWITCH BLOCK", .{});
1705 // std.debug.print("extra = {any}\n", .{extra});1706 // log.debug("extra = {any}", .{extra});
1706 // std.debug.print("outer_decl = {any}\n", .{self.types.items[type_index]});1707 // log.debug("outer_decl = {any}", .{self.types.items[type_index]});
1707 // std.debug.print("ast_lines = {}\n", .{ast_line});1708 // log.debug("ast_lines = {}", .{ast_line});
1708 // std.debug.print("{s}\n", .{sep});1709 // log.debug("{s}", .{sep});
17091710
1710 const switch_index = self.exprs.items.len;1711 const switch_index = self.exprs.items.len;
1711 try self.exprs.append(self.arena, .{ .switchOp = .{ .cond_index = cond_index, .file_name = file.sub_file_path, .ast = ast_index, .outer_decl = type_index } });1712 try self.exprs.append(self.arena, .{ .switchOp = .{ .cond_index = cond_index, .file_name = file.sub_file_path, .ast = ast_index, .outer_decl = type_index } });
...@@ -1728,11 +1729,11 @@ fn walkInstruction(...@@ -1728,11 +1729,11 @@ fn walkInstruction(
17281729
1729 // const ast_index = self.ast_nodes.items.len;1730 // const ast_index = self.ast_nodes.items.len;
1730 // const sep = "=" ** 200;1731 // const sep = "=" ** 200;
1731 // std.debug.print("{s}\n", .{sep});1732 // log.debug("{s}", .{sep});
1732 // std.debug.print("SWITCH COND\n", .{});1733 // log.debug("SWITCH COND", .{});
1733 // std.debug.print("ast index = {}\n", .{ast_index});1734 // log.debug("ast index = {}", .{ast_index});
1734 // std.debug.print("ast previous = {}\n", .{self.ast_nodes.items[ast_index - 1]});1735 // log.debug("ast previous = {}", .{self.ast_nodes.items[ast_index - 1]});
1735 // std.debug.print("{s}\n", .{sep});1736 // log.debug("{s}", .{sep});
17361737
1737 return DocData.WalkResult{1738 return DocData.WalkResult{
1738 .typeRef = operand.typeRef,1739 .typeRef = operand.typeRef,
...@@ -2209,12 +2210,12 @@ fn walkInstruction(...@@ -2209,12 +2210,12 @@ fn walkInstruction(
2209 _ = decls_bits;2210 _ = decls_bits;
22102211
2211 // const sep = "=" ** 200;2212 // const sep = "=" ** 200;
2212 // std.debug.print("{s}\n", .{sep});2213 // log.debug("{s}", .{sep});
2213 // std.debug.print("small = {any}\n", .{small});2214 // log.debug("small = {any}", .{small});
2214 // std.debug.print("src_node = {}\n", .{src_node});2215 // log.debug("src_node = {}", .{src_node});
2215 // std.debug.print("decls_len = {}\n", .{decls_len});2216 // log.debug("decls_len = {}", .{decls_len});
2216 // std.debug.print("decls_bit = {}\n", .{decls_bits});2217 // log.debug("decls_bit = {}", .{decls_bits});
2217 // std.debug.print("{s}\n", .{sep});2218 // log.debug("{s}", .{sep});
2218 const type_slot_index = self.types.items.len - 1;2219 const type_slot_index = self.types.items.len - 1;
2219 try self.types.append(self.arena, .{ .Opaque = .{ .name = "TODO" } });2220 try self.types.append(self.arena, .{ .Opaque = .{ .name = "TODO" } });
2220 return DocData.WalkResult{2221 return DocData.WalkResult{
...@@ -3860,9 +3861,7 @@ fn getBlockInlineBreak(zir: Zir, inst_index: usize) Zir.Inst.Ref {...@@ -3860,9 +3861,7 @@ fn getBlockInlineBreak(zir: Zir, inst_index: usize) Zir.Inst.Ref {
3860}3861}
38613862
3862fn printWithContext(file: *File, inst: usize, comptime fmt: []const u8, args: anytype) void {3863fn printWithContext(file: *File, inst: usize, comptime fmt: []const u8, args: anytype) void {
3863 std.debug.print("Context [{s}] % {}\n", .{ file.sub_file_path, inst });3864 log.debug("Context [{s}] % {} \n " ++ fmt, .{ file.sub_file_path, inst } ++ args);
3864 std.debug.print(fmt, args);
3865 std.debug.print("\n", .{});
3866}3865}
38673866
3868fn panicWithContext(file: *File, inst: usize, comptime fmt: []const u8, args: anytype) noreturn {3867fn panicWithContext(file: *File, inst: usize, comptime fmt: []const u8, args: anytype) noreturn {