authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-17 16:59:27-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-08-17 16:59:27-04:00
log624e643872130de5b6f6f1f120c8cf60a31f58e8
tree695ef653f88aef50bad66c46031e11d9a18d2751
parentc00d3d47f06abfc8321b132232586ccc4349cf02
parent16d118a8d9ce48143ef406ff7b3a1f9d62021d98
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #6046 from heidezomp/std-log-scoped-part2

std.log: (breaking) remove scope parameter from logging functions

7 files changed, 103 insertions(+), 149 deletions(-)

doc/langref.html.in+1-1
......@@ -325,7 +325,7 @@ pub fn main() !void {
325325 represents writing data to a file. When the disk is full, a write to the file will fail.
326326 However, we typically do not expect writing text to the standard output to fail. To avoid having
327327 to handle the failure case of printing to standard output, you can use alternate functions: the
328 <code>std.log</code> function for proper logging or the <code>std.debug.print</code> function.
328 functions in <code>std.log</code> for proper logging or the <code>std.debug.print</code> function.
329329 This documentation will use the latter option to print to standard error (stderr) and silently return
330330 on failure. The next code sample, <code>hello_again.zig</code> demonstrates the use of
331331 <code>std.debug.print</code>.
lib/std/heap/general_purpose_allocator.zig+5-4
......@@ -93,6 +93,7 @@
9393//! in a `std.HashMap` using the backing allocator.
9494
9595const std = @import("std");
96const log = std.log.scoped(.std);
9697const math = std.math;
9798const assert = std.debug.assert;
9899const mem = std.mem;
......@@ -288,7 +289,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
288289 if (is_used) {
289290 const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index);
290291 const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc);
291 std.log.err(.std, "Memory leak detected: {}", .{stack_trace});
292 log.err("Memory leak detected: {}", .{stack_trace});
292293 leaks = true;
293294 }
294295 if (bit_index == math.maxInt(u3))
......@@ -315,7 +316,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
315316 }
316317 }
317318 for (self.large_allocations.items()) |*large_alloc| {
318 std.log.err(.std, "Memory leak detected: {}", .{large_alloc.value.getStackTrace()});
319 log.err("Memory leak detected: {}", .{large_alloc.value.getStackTrace()});
319320 leaks = true;
320321 }
321322 return leaks;
......@@ -450,7 +451,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
450451 .index = 0,
451452 };
452453 std.debug.captureStackTrace(ret_addr, &free_stack_trace);
453 std.log.err(.std, "Allocation size {} bytes does not match free size {}. Allocation: {} Free: {}", .{
454 log.err("Allocation size {} bytes does not match free size {}. Allocation: {} Free: {}", .{
454455 entry.value.bytes.len,
455456 old_mem.len,
456457 entry.value.getStackTrace(),
......@@ -533,7 +534,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
533534 .index = 0,
534535 };
535536 std.debug.captureStackTrace(ret_addr, &second_free_stack_trace);
536 std.log.err(.std, "Double free detected. Allocation: {} First free: {} Second free: {}", .{
537 log.err("Double free detected. Allocation: {} First free: {} Second free: {}", .{
537538 alloc_stack_trace,
538539 free_stack_trace,
539540 second_free_stack_trace,
lib/std/log.zig+61-108
......@@ -6,12 +6,16 @@ const root = @import("root");
66//! of programs and libraries using this interface to be formatted and filtered
77//! by the implementer of the root.log function.
88//!
9//! The scope parameter should be used to give context to the logging. For
10//! example, a library called 'libfoo' might use .libfoo as its scope.
11//! This parameter can either be passed explicitly to the logging functions
12//! provided here, or a scoped logging namespace can be created
13//! using the `log.scoped` function. If logging scopes are not relevant for
14//! your use case, the `log.default` scope namespace can be used.
9//! Each log message has an associated scope enum, which can be used to give
10//! context to the logging. The logging functions in std.log implicitly use a
11//! scope of .default.
12//!
13//! A logging namespace using a custom scope can be created using the
14//! std.log.scoped function, passing the scope as an argument; the logging
15//! functions in the resulting struct use the provided scope parameter.
16//! For example, a library called 'libfoo' might use
17//! `const log = std.log.scoped(.libfoo);` to use .libfoo as the scope of its
18//! log messages.
1519//!
1620//! An example root.log might look something like this:
1721//!
......@@ -29,9 +33,9 @@ const root = @import("root");
2933//! args: anytype,
3034//! ) void {
3135//! // Ignore all non-critical logging from sources other than
32//! // .my_project and .nice_library
36//! // .my_project, .nice_library and .default
3337//! const scope_prefix = "(" ++ switch (scope) {
34//! .my_project, .nice_library => @tagName(scope),
38//! .my_project, .nice_library, .default => @tagName(scope),
3539//! else => if (@enumToInt(level) <= @enumToInt(std.log.Level.crit))
3640//! @tagName(scope)
3741//! else
......@@ -48,26 +52,24 @@ const root = @import("root");
4852//! }
4953//!
5054//! pub fn main() void {
51//! // Using explicit scopes:
52//! // Won't be printed as log_level is .warn
53//! std.log.info(.my_project, "Starting up.", .{});
54//! std.log.err(.nice_library, "Something went very wrong, sorry.", .{});
55//! // Won't be printed as it gets filtered out by our log function
56//! std.log.err(.lib_that_logs_too_much, "Added 1 + 1", .{});
55//! // Using the default scope:
56//! std.log.info("Just a simple informational log message", .{}); // Won't be printed as log_level is .warn
57//! std.log.warn("Flux capacitor is starting to overheat", .{});
5758//!
58//! // Using a scoped logging namespace:
59//! const scoped_log = std.log.scoped(.my_project);
60//! scoped_log.alert("The scope for this message is implicitly .my_project", .{});
59//! // Using scoped logging:
60//! const my_project_log = std.log.scoped(.my_project);
61//! const nice_library_log = std.log.scoped(.nice_library);
62//! const verbose_lib_log = std.log.scoped(.verbose_lib);
6163//!
62//! // Using the default namespace:
63//! // Won't be printed as log_level is .warn
64//! std.log.default.info("I don't care about my namespace", .{});
64//! my_project_log.info("Starting up", .{}); // Won't be printed as log_level is .warn
65//! nice_library_log.err("Something went very wrong, sorry", .{});
66//! verbose_lib_log.err("Added 1 + 1: {}", .{1 + 1}); // Won't be printed as it gets filtered out by our log function
6567//! }
6668//! ```
6769//! Which produces the following output:
6870//! ```
69//! [err] (nice_library): Something went very wrong, sorry.
70//! [alert] (my_project): The scope for this message is implicitly .my_project
71//! [warn] (default): Flux capacitor is starting to overheat
72//! [err] (nice_library): Something went very wrong, sorry
7173//! ```
7274
7375pub const Level = enum {
......@@ -129,92 +131,6 @@ fn log(
129131 }
130132}
131133
132/// Log an emergency message. This log level is intended to be used
133/// for conditions that cannot be handled and is usually followed by a panic.
134pub fn emerg(
135 comptime scope: @Type(.EnumLiteral),
136 comptime format: []const u8,
137 args: anytype,
138) void {
139 @setCold(true);
140 log(.emerg, scope, format, args);
141}
142
143/// Log an alert message. This log level is intended to be used for
144/// conditions that should be corrected immediately (e.g. database corruption).
145pub fn alert(
146 comptime scope: @Type(.EnumLiteral),
147 comptime format: []const u8,
148 args: anytype,
149) void {
150 @setCold(true);
151 log(.alert, scope, format, args);
152}
153
154/// Log a critical message. This log level is intended to be used
155/// when a bug has been detected or something has gone wrong and it will have
156/// an effect on the operation of the program.
157pub fn crit(
158 comptime scope: @Type(.EnumLiteral),
159 comptime format: []const u8,
160 args: anytype,
161) void {
162 @setCold(true);
163 log(.crit, scope, format, args);
164}
165
166/// Log an error message. This log level is intended to be used when
167/// a bug has been detected or something has gone wrong but it is recoverable.
168pub fn err(
169 comptime scope: @Type(.EnumLiteral),
170 comptime format: []const u8,
171 args: anytype,
172) void {
173 @setCold(true);
174 log(.err, scope, format, args);
175}
176
177/// Log a warning message. This log level is intended to be used if
178/// it is uncertain whether something has gone wrong or not, but the
179/// circumstances would be worth investigating.
180pub fn warn(
181 comptime scope: @Type(.EnumLiteral),
182 comptime format: []const u8,
183 args: anytype,
184) void {
185 log(.warn, scope, format, args);
186}
187
188/// Log a notice message. This log level is intended to be used for
189/// non-error but significant conditions.
190pub fn notice(
191 comptime scope: @Type(.EnumLiteral),
192 comptime format: []const u8,
193 args: anytype,
194) void {
195 log(.notice, scope, format, args);
196}
197
198/// Log an info message. This log level is intended to be used for
199/// general messages about the state of the program.
200pub fn info(
201 comptime scope: @Type(.EnumLiteral),
202 comptime format: []const u8,
203 args: anytype,
204) void {
205 log(.info, scope, format, args);
206}
207
208/// Log a debug message. This log level is intended to be used for
209/// messages which are only useful for debugging.
210pub fn debug(
211 comptime scope: @Type(.EnumLiteral),
212 comptime format: []const u8,
213 args: anytype,
214) void {
215 log(.debug, scope, format, args);
216}
217
218134/// Returns a scoped logging namespace that logs all messages using the scope
219135/// provided here.
220136pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
......@@ -301,3 +217,40 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
301217
302218/// The default scoped logging namespace.
303219pub const default = scoped(.default);
220
221/// Log an emergency message using the default scope. This log level is
222/// intended to be used for conditions that cannot be handled and is usually
223/// followed by a panic.
224pub const emerg = default.emerg;
225
226/// Log an alert message using the default scope. This log level is intended to
227/// be used for conditions that should be corrected immediately (e.g. database
228/// corruption).
229pub const alert = default.alert;
230
231/// Log a critical message using the default scope. This log level is intended
232/// to be used when a bug has been detected or something has gone wrong and it
233/// will have an effect on the operation of the program.
234pub const crit = default.crit;
235
236/// Log an error message using the default scope. This log level is intended to
237/// be used when a bug has been detected or something has gone wrong but it is
238/// recoverable.
239pub const err = default.err;
240
241/// Log a warning message using the default scope. This log level is intended
242/// to be used if it is uncertain whether something has gone wrong or not, but
243/// the circumstances would be worth investigating.
244pub const warn = default.warn;
245
246/// Log a notice message using the default scope. This log level is intended to
247/// be used for non-error but significant conditions.
248pub const notice = default.notice;
249
250/// Log an info message using the default scope. This log level is intended to
251/// be used for general messages about the state of the program.
252pub const info = default.info;
253
254/// Log a debug message using the default scope. This log level is intended to
255/// be used for messages which are only useful for debugging.
256pub const debug = default.debug;
src-self-hosted/Module.zig+9-9
......@@ -6,7 +6,7 @@ const Value = @import("value.zig").Value;
66const Type = @import("type.zig").Type;
77const TypedValue = @import("TypedValue.zig");
88const assert = std.debug.assert;
9const log = std.log;
9const log = std.log.scoped(.module);
1010const BigIntConst = std.math.big.int.Const;
1111const BigIntMutable = std.math.big.int.Mutable;
1212const Target = std.Target;
......@@ -1079,7 +1079,7 @@ pub fn performAllTheWork(self: *Module) error{OutOfMemory}!void {
10791079 // lifetime annotations in the ZIR.
10801080 var decl_arena = decl.typed_value.most_recent.arena.?.promote(self.gpa);
10811081 defer decl.typed_value.most_recent.arena.?.* = decl_arena.state;
1082 std.log.debug(.module, "analyze liveness of {}\n", .{decl.name});
1082 log.debug("analyze liveness of {}\n", .{decl.name});
10831083 try liveness.analyze(self.gpa, &decl_arena.allocator, payload.func.analysis.success);
10841084 }
10851085
......@@ -1141,7 +1141,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void {
11411141 .complete => return,
11421142
11431143 .outdated => blk: {
1144 log.debug(.module, "re-analyzing {}\n", .{decl.name});
1144 log.debug("re-analyzing {}\n", .{decl.name});
11451145
11461146 // The exports this Decl performs will be re-discovered, so we remove them here
11471147 // prior to re-analysis.
......@@ -1592,7 +1592,7 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void {
15921592 // Handle explicitly deleted decls from the source code. Not to be confused
15931593 // with when we delete decls because they are no longer referenced.
15941594 for (deleted_decls.items()) |entry| {
1595 log.debug(.module, "noticed '{}' deleted from source\n", .{entry.key.name});
1595 log.debug("noticed '{}' deleted from source\n", .{entry.key.name});
15961596 try self.deleteDecl(entry.key);
15971597 }
15981598}
......@@ -1645,7 +1645,7 @@ fn analyzeRootZIRModule(self: *Module, root_scope: *Scope.ZIRModule) !void {
16451645 // Handle explicitly deleted decls from the source code. Not to be confused
16461646 // with when we delete decls because they are no longer referenced.
16471647 for (deleted_decls.items()) |entry| {
1648 log.debug(.module, "noticed '{}' deleted from source\n", .{entry.key.name});
1648 log.debug("noticed '{}' deleted from source\n", .{entry.key.name});
16491649 try self.deleteDecl(entry.key);
16501650 }
16511651}
......@@ -1657,7 +1657,7 @@ fn deleteDecl(self: *Module, decl: *Decl) !void {
16571657 // not be present in the set, and this does nothing.
16581658 decl.scope.removeDecl(decl);
16591659
1660 log.debug(.module, "deleting decl '{}'\n", .{decl.name});
1660 log.debug("deleting decl '{}'\n", .{decl.name});
16611661 const name_hash = decl.fullyQualifiedNameHash();
16621662 self.decl_table.removeAssertDiscard(name_hash);
16631663 // Remove itself from its dependencies, because we are about to destroy the decl pointer.
......@@ -1744,17 +1744,17 @@ fn analyzeFnBody(self: *Module, decl: *Decl, func: *Fn) !void {
17441744 const fn_zir = func.analysis.queued;
17451745 defer fn_zir.arena.promote(self.gpa).deinit();
17461746 func.analysis = .{ .in_progress = {} };
1747 log.debug(.module, "set {} to in_progress\n", .{decl.name});
1747 log.debug("set {} to in_progress\n", .{decl.name});
17481748
17491749 try zir_sema.analyzeBody(self, &inner_block.base, fn_zir.body);
17501750
17511751 const instructions = try arena.allocator.dupe(*Inst, inner_block.instructions.items);
17521752 func.analysis = .{ .success = .{ .instructions = instructions } };
1753 log.debug(.module, "set {} to success\n", .{decl.name});
1753 log.debug("set {} to success\n", .{decl.name});
17541754}
17551755
17561756fn markOutdatedDecl(self: *Module, decl: *Decl) !void {
1757 log.debug(.module, "mark {} outdated\n", .{decl.name});
1757 log.debug("mark {} outdated\n", .{decl.name});
17581758 try self.work_queue.writeItem(.{ .analyze_decl = decl });
17591759 if (self.failed_decls.remove(decl)) |entry| {
17601760 entry.value.destroy(self.gpa);
src-self-hosted/link.zig+25-25
......@@ -8,7 +8,7 @@ const fs = std.fs;
88const elf = std.elf;
99const codegen = @import("codegen.zig");
1010const c_codegen = @import("codegen/c.zig");
11const log = std.log;
11const log = std.log.scoped(.link);
1212const DW = std.dwarf;
1313const trace = @import("tracy.zig").trace;
1414const leb128 = std.debug.leb;
......@@ -746,7 +746,7 @@ pub const File = struct {
746746 const file_size = self.base.options.program_code_size_hint;
747747 const p_align = 0x1000;
748748 const off = self.findFreeSpace(file_size, p_align);
749 log.debug(.link, "found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
749 log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
750750 try self.program_headers.append(self.base.allocator, .{
751751 .p_type = elf.PT_LOAD,
752752 .p_offset = off,
......@@ -767,7 +767,7 @@ pub const File = struct {
767767 // page align.
768768 const p_align = if (self.base.options.target.os.tag == .linux) 0x1000 else @as(u16, ptr_size);
769769 const off = self.findFreeSpace(file_size, p_align);
770 log.debug(.link, "found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
770 log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
771771 // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at.
772772 // we'll need to re-use that function anyway, in case the GOT grows and overlaps something
773773 // else in virtual memory.
......@@ -789,7 +789,7 @@ pub const File = struct {
789789 assert(self.shstrtab.items.len == 0);
790790 try self.shstrtab.append(self.base.allocator, 0); // need a 0 at position 0
791791 const off = self.findFreeSpace(self.shstrtab.items.len, 1);
792 log.debug(.link, "found shstrtab free space 0x{x} to 0x{x}\n", .{ off, off + self.shstrtab.items.len });
792 log.debug("found shstrtab free space 0x{x} to 0x{x}\n", .{ off, off + self.shstrtab.items.len });
793793 try self.sections.append(self.base.allocator, .{
794794 .sh_name = try self.makeString(".shstrtab"),
795795 .sh_type = elf.SHT_STRTAB,
......@@ -847,7 +847,7 @@ pub const File = struct {
847847 const each_size: u64 = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym);
848848 const file_size = self.base.options.symbol_count_hint * each_size;
849849 const off = self.findFreeSpace(file_size, min_align);
850 log.debug(.link, "found symtab free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
850 log.debug("found symtab free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
851851
852852 try self.sections.append(self.base.allocator, .{
853853 .sh_name = try self.makeString(".symtab"),
......@@ -889,7 +889,7 @@ pub const File = struct {
889889 const file_size_hint = 200;
890890 const p_align = 1;
891891 const off = self.findFreeSpace(file_size_hint, p_align);
892 log.debug(.link, "found .debug_info free space 0x{x} to 0x{x}\n", .{
892 log.debug("found .debug_info free space 0x{x} to 0x{x}\n", .{
893893 off,
894894 off + file_size_hint,
895895 });
......@@ -914,7 +914,7 @@ pub const File = struct {
914914 const file_size_hint = 128;
915915 const p_align = 1;
916916 const off = self.findFreeSpace(file_size_hint, p_align);
917 log.debug(.link, "found .debug_abbrev free space 0x{x} to 0x{x}\n", .{
917 log.debug("found .debug_abbrev free space 0x{x} to 0x{x}\n", .{
918918 off,
919919 off + file_size_hint,
920920 });
......@@ -939,7 +939,7 @@ pub const File = struct {
939939 const file_size_hint = 160;
940940 const p_align = 16;
941941 const off = self.findFreeSpace(file_size_hint, p_align);
942 log.debug(.link, "found .debug_aranges free space 0x{x} to 0x{x}\n", .{
942 log.debug("found .debug_aranges free space 0x{x} to 0x{x}\n", .{
943943 off,
944944 off + file_size_hint,
945945 });
......@@ -964,7 +964,7 @@ pub const File = struct {
964964 const file_size_hint = 250;
965965 const p_align = 1;
966966 const off = self.findFreeSpace(file_size_hint, p_align);
967 log.debug(.link, "found .debug_line free space 0x{x} to 0x{x}\n", .{
967 log.debug("found .debug_line free space 0x{x} to 0x{x}\n", .{
968968 off,
969969 off + file_size_hint,
970970 });
......@@ -1090,7 +1090,7 @@ pub const File = struct {
10901090 debug_abbrev_sect.sh_offset = self.findFreeSpace(needed_size, 1);
10911091 }
10921092 debug_abbrev_sect.sh_size = needed_size;
1093 log.debug(.link, ".debug_abbrev start=0x{x} end=0x{x}\n", .{
1093 log.debug(".debug_abbrev start=0x{x} end=0x{x}\n", .{
10941094 debug_abbrev_sect.sh_offset,
10951095 debug_abbrev_sect.sh_offset + needed_size,
10961096 });
......@@ -1237,7 +1237,7 @@ pub const File = struct {
12371237 debug_aranges_sect.sh_offset = self.findFreeSpace(needed_size, 16);
12381238 }
12391239 debug_aranges_sect.sh_size = needed_size;
1240 log.debug(.link, ".debug_aranges start=0x{x} end=0x{x}\n", .{
1240 log.debug(".debug_aranges start=0x{x} end=0x{x}\n", .{
12411241 debug_aranges_sect.sh_offset,
12421242 debug_aranges_sect.sh_offset + needed_size,
12431243 });
......@@ -1405,7 +1405,7 @@ pub const File = struct {
14051405 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
14061406 }
14071407 shstrtab_sect.sh_size = needed_size;
1408 log.debug(.link, "writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });
1408 log.debug("writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });
14091409
14101410 try self.base.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);
14111411 if (!self.shdr_table_dirty) {
......@@ -1426,7 +1426,7 @@ pub const File = struct {
14261426 debug_strtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
14271427 }
14281428 debug_strtab_sect.sh_size = needed_size;
1429 log.debug(.link, "debug_strtab start=0x{x} end=0x{x}\n", .{ debug_strtab_sect.sh_offset, debug_strtab_sect.sh_offset + needed_size });
1429 log.debug("debug_strtab start=0x{x} end=0x{x}\n", .{ debug_strtab_sect.sh_offset, debug_strtab_sect.sh_offset + needed_size });
14301430
14311431 try self.base.file.?.pwriteAll(self.debug_strtab.items, debug_strtab_sect.sh_offset);
14321432 if (!self.shdr_table_dirty) {
......@@ -1460,7 +1460,7 @@ pub const File = struct {
14601460
14611461 for (buf) |*shdr, i| {
14621462 shdr.* = sectHeaderTo32(self.sections.items[i]);
1463 std.log.debug(.link, "writing section {}\n", .{shdr.*});
1463 log.debug("writing section {}\n", .{shdr.*});
14641464 if (foreign_endian) {
14651465 bswapAllFields(elf.Elf32_Shdr, shdr);
14661466 }
......@@ -1473,7 +1473,7 @@ pub const File = struct {
14731473
14741474 for (buf) |*shdr, i| {
14751475 shdr.* = self.sections.items[i];
1476 log.debug(.link, "writing section {}\n", .{shdr.*});
1476 log.debug("writing section {}\n", .{shdr.*});
14771477 if (foreign_endian) {
14781478 bswapAllFields(elf.Elf64_Shdr, shdr);
14791479 }
......@@ -1484,10 +1484,10 @@ pub const File = struct {
14841484 self.shdr_table_dirty = false;
14851485 }
14861486 if (self.entry_addr == null and self.base.options.output_mode == .Exe) {
1487 log.debug(.link, "flushing. no_entry_point_found = true\n", .{});
1487 log.debug("flushing. no_entry_point_found = true\n", .{});
14881488 self.error_flags.no_entry_point_found = true;
14891489 } else {
1490 log.debug(.link, "flushing. no_entry_point_found = false\n", .{});
1490 log.debug("flushing. no_entry_point_found = false\n", .{});
14911491 self.error_flags.no_entry_point_found = false;
14921492 try self.writeElfHeader();
14931493 }
......@@ -1816,10 +1816,10 @@ pub const File = struct {
18161816 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
18171817
18181818 if (self.local_symbol_free_list.popOrNull()) |i| {
1819 log.debug(.link, "reusing symbol index {} for {}\n", .{ i, decl.name });
1819 log.debug("reusing symbol index {} for {}\n", .{ i, decl.name });
18201820 decl.link.elf.local_sym_index = i;
18211821 } else {
1822 log.debug(.link, "allocating symbol index {} for {}\n", .{ self.local_symbols.items.len, decl.name });
1822 log.debug("allocating symbol index {} for {}\n", .{ self.local_symbols.items.len, decl.name });
18231823 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);
18241824 _ = self.local_symbols.addOneAssumeCapacity();
18251825 }
......@@ -2016,11 +2016,11 @@ pub const File = struct {
20162016 !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment);
20172017 if (need_realloc) {
20182018 const vaddr = try self.growTextBlock(&decl.link.elf, code.len, required_alignment);
2019 log.debug(.link, "growing {} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });
2019 log.debug("growing {} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });
20202020 if (vaddr != local_sym.st_value) {
20212021 local_sym.st_value = vaddr;
20222022
2023 log.debug(.link, " (writing new offset table entry)\n", .{});
2023 log.debug(" (writing new offset table entry)\n", .{});
20242024 self.offset_table.items[decl.link.elf.offset_table_index] = vaddr;
20252025 try self.writeOffsetTableEntry(decl.link.elf.offset_table_index);
20262026 }
......@@ -2038,7 +2038,7 @@ pub const File = struct {
20382038 const decl_name = mem.spanZ(decl.name);
20392039 const name_str_index = try self.makeString(decl_name);
20402040 const vaddr = try self.allocateTextBlock(&decl.link.elf, code.len, required_alignment);
2041 log.debug(.link, "allocated text block for {} at 0x{x}\n", .{ decl_name, vaddr });
2041 log.debug("allocated text block for {} at 0x{x}\n", .{ decl_name, vaddr });
20422042 errdefer self.freeTextBlock(&decl.link.elf);
20432043
20442044 local_sym.* = .{
......@@ -2148,7 +2148,7 @@ pub const File = struct {
21482148 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
21492149 const new_offset = self.findFreeSpace(needed_size, 1);
21502150 const existing_size = last_src_fn.off;
2151 log.debug(.link, "moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{
2151 log.debug("moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{
21522152 existing_size,
21532153 debug_line_sect.sh_offset,
21542154 new_offset,
......@@ -2227,7 +2227,7 @@ pub const File = struct {
22272227 try dbg_info_buffer.writer().print("{}\x00", .{ty});
22282228 },
22292229 else => {
2230 log.err(.compiler, "TODO implement .debug_info for type '{}'", .{ty});
2230 std.log.scoped(.compiler).err("TODO implement .debug_info for type '{}'", .{ty});
22312231 try dbg_info_buffer.append(abbrev_pad1);
22322232 },
22332233 }
......@@ -2299,7 +2299,7 @@ pub const File = struct {
22992299 if (needed_size > self.allocatedSize(debug_info_sect.sh_offset)) {
23002300 const new_offset = self.findFreeSpace(needed_size, 1);
23012301 const existing_size = last_decl.dbg_info_off;
2302 log.debug(.link, "moving .debug_info section: {} bytes from 0x{x} to 0x{x}\n", .{
2302 log.debug("moving .debug_info section: {} bytes from 0x{x} to 0x{x}\n", .{
23032303 existing_size,
23042304 debug_info_sect.sh_offset,
23052305 new_offset,
src-self-hosted/liveness.zig+1-1
......@@ -151,5 +151,5 @@ fn analyzeInst(
151151 @panic("Handle liveness analysis for instructions with many parameters");
152152 }
153153
154 std.log.debug(.liveness, "analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
154 std.log.scoped(.liveness).debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
155155}
src-self-hosted/main.zig+1-1
......@@ -557,7 +557,7 @@ fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !vo
557557 });
558558 }
559559 } else {
560 std.log.info(.compiler, "Update completed in {} ms\n", .{update_nanos / std.time.ns_per_ms});
560 std.log.scoped(.compiler).info("Update completed in {} ms\n", .{update_nanos / std.time.ns_per_ms});
561561 }
562562
563563 if (zir_out_path) |zop| {