| author | |
| committer | |
| log | 624e643872130de5b6f6f1f120c8cf60a31f58e8 |
| tree | 695ef653f88aef50bad66c46031e11d9a18d2751 |
| parent | c00d3d47f06abfc8321b132232586ccc4349cf02 |
| parent | 16d118a8d9ce48143ef406ff7b3a1f9d62021d98 |
| signature |
std.log: (breaking) remove scope parameter from logging functions7 files changed, 103 insertions(+), 149 deletions(-)
doc/langref.html.in+1-1| ... | ... | @@ -325,7 +325,7 @@ pub fn main() !void { |
| 325 | 325 | represents writing data to a file. When the disk is full, a write to the file will fail. |
| 326 | 326 | However, we typically do not expect writing text to the standard output to fail. To avoid having |
| 327 | 327 | 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. | |
| 329 | 329 | This documentation will use the latter option to print to standard error (stderr) and silently return |
| 330 | 330 | on failure. The next code sample, <code>hello_again.zig</code> demonstrates the use of |
| 331 | 331 | <code>std.debug.print</code>. |
lib/std/heap/general_purpose_allocator.zig+5-4| ... | ... | @@ -93,6 +93,7 @@ |
| 93 | 93 | //! in a `std.HashMap` using the backing allocator. |
| 94 | 94 | |
| 95 | 95 | const std = @import("std"); |
| 96 | const log = std.log.scoped(.std); | |
| 96 | 97 | const math = std.math; |
| 97 | 98 | const assert = std.debug.assert; |
| 98 | 99 | const mem = std.mem; |
| ... | ... | @@ -288,7 +289,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 288 | 289 | if (is_used) { |
| 289 | 290 | const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index); |
| 290 | 291 | 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}); | |
| 292 | 293 | leaks = true; |
| 293 | 294 | } |
| 294 | 295 | if (bit_index == math.maxInt(u3)) |
| ... | ... | @@ -315,7 +316,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 315 | 316 | } |
| 316 | 317 | } |
| 317 | 318 | 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()}); | |
| 319 | 320 | leaks = true; |
| 320 | 321 | } |
| 321 | 322 | return leaks; |
| ... | ... | @@ -450,7 +451,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 450 | 451 | .index = 0, |
| 451 | 452 | }; |
| 452 | 453 | 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: {}", .{ | |
| 454 | 455 | entry.value.bytes.len, |
| 455 | 456 | old_mem.len, |
| 456 | 457 | entry.value.getStackTrace(), |
| ... | ... | @@ -533,7 +534,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 533 | 534 | .index = 0, |
| 534 | 535 | }; |
| 535 | 536 | 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: {}", .{ | |
| 537 | 538 | alloc_stack_trace, |
| 538 | 539 | free_stack_trace, |
| 539 | 540 | second_free_stack_trace, |
lib/std/log.zig+61-108| ... | ... | @@ -6,12 +6,16 @@ const root = @import("root"); |
| 6 | 6 | //! of programs and libraries using this interface to be formatted and filtered |
| 7 | 7 | //! by the implementer of the root.log function. |
| 8 | 8 | //! |
| 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. | |
| 15 | 19 | //! |
| 16 | 20 | //! An example root.log might look something like this: |
| 17 | 21 | //! |
| ... | ... | @@ -29,9 +33,9 @@ const root = @import("root"); |
| 29 | 33 | //! args: anytype, |
| 30 | 34 | //! ) void { |
| 31 | 35 | //! // Ignore all non-critical logging from sources other than |
| 32 | //! // .my_project and .nice_library | |
| 36 | //! // .my_project, .nice_library and .default | |
| 33 | 37 | //! const scope_prefix = "(" ++ switch (scope) { |
| 34 | //! .my_project, .nice_library => @tagName(scope), | |
| 38 | //! .my_project, .nice_library, .default => @tagName(scope), | |
| 35 | 39 | //! else => if (@enumToInt(level) <= @enumToInt(std.log.Level.crit)) |
| 36 | 40 | //! @tagName(scope) |
| 37 | 41 | //! else |
| ... | ... | @@ -48,26 +52,24 @@ const root = @import("root"); |
| 48 | 52 | //! } |
| 49 | 53 | //! |
| 50 | 54 | //! 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", .{}); | |
| 57 | 58 | //! |
| 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); | |
| 61 | 63 | //! |
| 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 | |
| 65 | 67 | //! } |
| 66 | 68 | //! ``` |
| 67 | 69 | //! Which produces the following output: |
| 68 | 70 | //! ``` |
| 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 | |
| 71 | 73 | //! ``` |
| 72 | 74 | |
| 73 | 75 | pub const Level = enum { |
| ... | ... | @@ -129,92 +131,6 @@ fn log( |
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | |
| 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. | |
| 134 | pub 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). | |
| 145 | pub 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. | |
| 157 | pub 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. | |
| 168 | pub 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. | |
| 180 | pub 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. | |
| 190 | pub 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. | |
| 200 | pub 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. | |
| 210 | pub 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 | ||
| 218 | 134 | /// Returns a scoped logging namespace that logs all messages using the scope |
| 219 | 135 | /// provided here. |
| 220 | 136 | pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { |
| ... | ... | @@ -301,3 +217,40 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { |
| 301 | 217 | |
| 302 | 218 | /// The default scoped logging namespace. |
| 303 | 219 | pub 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. | |
| 224 | pub 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). | |
| 229 | pub 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. | |
| 234 | pub 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. | |
| 239 | pub 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. | |
| 244 | pub 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. | |
| 248 | pub 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. | |
| 252 | pub 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. | |
| 256 | pub const debug = default.debug; |
src-self-hosted/Module.zig+9-9| ... | ... | @@ -6,7 +6,7 @@ const Value = @import("value.zig").Value; |
| 6 | 6 | const Type = @import("type.zig").Type; |
| 7 | 7 | const TypedValue = @import("TypedValue.zig"); |
| 8 | 8 | const assert = std.debug.assert; |
| 9 | const log = std.log; | |
| 9 | const log = std.log.scoped(.module); | |
| 10 | 10 | const BigIntConst = std.math.big.int.Const; |
| 11 | 11 | const BigIntMutable = std.math.big.int.Mutable; |
| 12 | 12 | const Target = std.Target; |
| ... | ... | @@ -1079,7 +1079,7 @@ pub fn performAllTheWork(self: *Module) error{OutOfMemory}!void { |
| 1079 | 1079 | // lifetime annotations in the ZIR. |
| 1080 | 1080 | var decl_arena = decl.typed_value.most_recent.arena.?.promote(self.gpa); |
| 1081 | 1081 | 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}); | |
| 1083 | 1083 | try liveness.analyze(self.gpa, &decl_arena.allocator, payload.func.analysis.success); |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| ... | ... | @@ -1141,7 +1141,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void { |
| 1141 | 1141 | .complete => return, |
| 1142 | 1142 | |
| 1143 | 1143 | .outdated => blk: { |
| 1144 | log.debug(.module, "re-analyzing {}\n", .{decl.name}); | |
| 1144 | log.debug("re-analyzing {}\n", .{decl.name}); | |
| 1145 | 1145 | |
| 1146 | 1146 | // The exports this Decl performs will be re-discovered, so we remove them here |
| 1147 | 1147 | // prior to re-analysis. |
| ... | ... | @@ -1592,7 +1592,7 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void { |
| 1592 | 1592 | // Handle explicitly deleted decls from the source code. Not to be confused |
| 1593 | 1593 | // with when we delete decls because they are no longer referenced. |
| 1594 | 1594 | 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}); | |
| 1596 | 1596 | try self.deleteDecl(entry.key); |
| 1597 | 1597 | } |
| 1598 | 1598 | } |
| ... | ... | @@ -1645,7 +1645,7 @@ fn analyzeRootZIRModule(self: *Module, root_scope: *Scope.ZIRModule) !void { |
| 1645 | 1645 | // Handle explicitly deleted decls from the source code. Not to be confused |
| 1646 | 1646 | // with when we delete decls because they are no longer referenced. |
| 1647 | 1647 | 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}); | |
| 1649 | 1649 | try self.deleteDecl(entry.key); |
| 1650 | 1650 | } |
| 1651 | 1651 | } |
| ... | ... | @@ -1657,7 +1657,7 @@ fn deleteDecl(self: *Module, decl: *Decl) !void { |
| 1657 | 1657 | // not be present in the set, and this does nothing. |
| 1658 | 1658 | decl.scope.removeDecl(decl); |
| 1659 | 1659 | |
| 1660 | log.debug(.module, "deleting decl '{}'\n", .{decl.name}); | |
| 1660 | log.debug("deleting decl '{}'\n", .{decl.name}); | |
| 1661 | 1661 | const name_hash = decl.fullyQualifiedNameHash(); |
| 1662 | 1662 | self.decl_table.removeAssertDiscard(name_hash); |
| 1663 | 1663 | // 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 { |
| 1744 | 1744 | const fn_zir = func.analysis.queued; |
| 1745 | 1745 | defer fn_zir.arena.promote(self.gpa).deinit(); |
| 1746 | 1746 | 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}); | |
| 1748 | 1748 | |
| 1749 | 1749 | try zir_sema.analyzeBody(self, &inner_block.base, fn_zir.body); |
| 1750 | 1750 | |
| 1751 | 1751 | const instructions = try arena.allocator.dupe(*Inst, inner_block.instructions.items); |
| 1752 | 1752 | func.analysis = .{ .success = .{ .instructions = instructions } }; |
| 1753 | log.debug(.module, "set {} to success\n", .{decl.name}); | |
| 1753 | log.debug("set {} to success\n", .{decl.name}); | |
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | 1756 | fn markOutdatedDecl(self: *Module, decl: *Decl) !void { |
| 1757 | log.debug(.module, "mark {} outdated\n", .{decl.name}); | |
| 1757 | log.debug("mark {} outdated\n", .{decl.name}); | |
| 1758 | 1758 | try self.work_queue.writeItem(.{ .analyze_decl = decl }); |
| 1759 | 1759 | if (self.failed_decls.remove(decl)) |entry| { |
| 1760 | 1760 | entry.value.destroy(self.gpa); |
src-self-hosted/link.zig+25-25| ... | ... | @@ -8,7 +8,7 @@ const fs = std.fs; |
| 8 | 8 | const elf = std.elf; |
| 9 | 9 | const codegen = @import("codegen.zig"); |
| 10 | 10 | const c_codegen = @import("codegen/c.zig"); |
| 11 | const log = std.log; | |
| 11 | const log = std.log.scoped(.link); | |
| 12 | 12 | const DW = std.dwarf; |
| 13 | 13 | const trace = @import("tracy.zig").trace; |
| 14 | 14 | const leb128 = std.debug.leb; |
| ... | ... | @@ -746,7 +746,7 @@ pub const File = struct { |
| 746 | 746 | const file_size = self.base.options.program_code_size_hint; |
| 747 | 747 | const p_align = 0x1000; |
| 748 | 748 | 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 }); | |
| 750 | 750 | try self.program_headers.append(self.base.allocator, .{ |
| 751 | 751 | .p_type = elf.PT_LOAD, |
| 752 | 752 | .p_offset = off, |
| ... | ... | @@ -767,7 +767,7 @@ pub const File = struct { |
| 767 | 767 | // page align. |
| 768 | 768 | const p_align = if (self.base.options.target.os.tag == .linux) 0x1000 else @as(u16, ptr_size); |
| 769 | 769 | 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 }); | |
| 771 | 771 | // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at. |
| 772 | 772 | // we'll need to re-use that function anyway, in case the GOT grows and overlaps something |
| 773 | 773 | // else in virtual memory. |
| ... | ... | @@ -789,7 +789,7 @@ pub const File = struct { |
| 789 | 789 | assert(self.shstrtab.items.len == 0); |
| 790 | 790 | try self.shstrtab.append(self.base.allocator, 0); // need a 0 at position 0 |
| 791 | 791 | 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 }); | |
| 793 | 793 | try self.sections.append(self.base.allocator, .{ |
| 794 | 794 | .sh_name = try self.makeString(".shstrtab"), |
| 795 | 795 | .sh_type = elf.SHT_STRTAB, |
| ... | ... | @@ -847,7 +847,7 @@ pub const File = struct { |
| 847 | 847 | const each_size: u64 = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym); |
| 848 | 848 | const file_size = self.base.options.symbol_count_hint * each_size; |
| 849 | 849 | 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 }); | |
| 851 | 851 | |
| 852 | 852 | try self.sections.append(self.base.allocator, .{ |
| 853 | 853 | .sh_name = try self.makeString(".symtab"), |
| ... | ... | @@ -889,7 +889,7 @@ pub const File = struct { |
| 889 | 889 | const file_size_hint = 200; |
| 890 | 890 | const p_align = 1; |
| 891 | 891 | 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", .{ | |
| 893 | 893 | off, |
| 894 | 894 | off + file_size_hint, |
| 895 | 895 | }); |
| ... | ... | @@ -914,7 +914,7 @@ pub const File = struct { |
| 914 | 914 | const file_size_hint = 128; |
| 915 | 915 | const p_align = 1; |
| 916 | 916 | 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", .{ | |
| 918 | 918 | off, |
| 919 | 919 | off + file_size_hint, |
| 920 | 920 | }); |
| ... | ... | @@ -939,7 +939,7 @@ pub const File = struct { |
| 939 | 939 | const file_size_hint = 160; |
| 940 | 940 | const p_align = 16; |
| 941 | 941 | 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", .{ | |
| 943 | 943 | off, |
| 944 | 944 | off + file_size_hint, |
| 945 | 945 | }); |
| ... | ... | @@ -964,7 +964,7 @@ pub const File = struct { |
| 964 | 964 | const file_size_hint = 250; |
| 965 | 965 | const p_align = 1; |
| 966 | 966 | 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", .{ | |
| 968 | 968 | off, |
| 969 | 969 | off + file_size_hint, |
| 970 | 970 | }); |
| ... | ... | @@ -1090,7 +1090,7 @@ pub const File = struct { |
| 1090 | 1090 | debug_abbrev_sect.sh_offset = self.findFreeSpace(needed_size, 1); |
| 1091 | 1091 | } |
| 1092 | 1092 | 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", .{ | |
| 1094 | 1094 | debug_abbrev_sect.sh_offset, |
| 1095 | 1095 | debug_abbrev_sect.sh_offset + needed_size, |
| 1096 | 1096 | }); |
| ... | ... | @@ -1237,7 +1237,7 @@ pub const File = struct { |
| 1237 | 1237 | debug_aranges_sect.sh_offset = self.findFreeSpace(needed_size, 16); |
| 1238 | 1238 | } |
| 1239 | 1239 | 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", .{ | |
| 1241 | 1241 | debug_aranges_sect.sh_offset, |
| 1242 | 1242 | debug_aranges_sect.sh_offset + needed_size, |
| 1243 | 1243 | }); |
| ... | ... | @@ -1405,7 +1405,7 @@ pub const File = struct { |
| 1405 | 1405 | shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1); |
| 1406 | 1406 | } |
| 1407 | 1407 | 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 }); | |
| 1409 | 1409 | |
| 1410 | 1410 | try self.base.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset); |
| 1411 | 1411 | if (!self.shdr_table_dirty) { |
| ... | ... | @@ -1426,7 +1426,7 @@ pub const File = struct { |
| 1426 | 1426 | debug_strtab_sect.sh_offset = self.findFreeSpace(needed_size, 1); |
| 1427 | 1427 | } |
| 1428 | 1428 | 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 }); | |
| 1430 | 1430 | |
| 1431 | 1431 | try self.base.file.?.pwriteAll(self.debug_strtab.items, debug_strtab_sect.sh_offset); |
| 1432 | 1432 | if (!self.shdr_table_dirty) { |
| ... | ... | @@ -1460,7 +1460,7 @@ pub const File = struct { |
| 1460 | 1460 | |
| 1461 | 1461 | for (buf) |*shdr, i| { |
| 1462 | 1462 | shdr.* = sectHeaderTo32(self.sections.items[i]); |
| 1463 | std.log.debug(.link, "writing section {}\n", .{shdr.*}); | |
| 1463 | log.debug("writing section {}\n", .{shdr.*}); | |
| 1464 | 1464 | if (foreign_endian) { |
| 1465 | 1465 | bswapAllFields(elf.Elf32_Shdr, shdr); |
| 1466 | 1466 | } |
| ... | ... | @@ -1473,7 +1473,7 @@ pub const File = struct { |
| 1473 | 1473 | |
| 1474 | 1474 | for (buf) |*shdr, i| { |
| 1475 | 1475 | shdr.* = self.sections.items[i]; |
| 1476 | log.debug(.link, "writing section {}\n", .{shdr.*}); | |
| 1476 | log.debug("writing section {}\n", .{shdr.*}); | |
| 1477 | 1477 | if (foreign_endian) { |
| 1478 | 1478 | bswapAllFields(elf.Elf64_Shdr, shdr); |
| 1479 | 1479 | } |
| ... | ... | @@ -1484,10 +1484,10 @@ pub const File = struct { |
| 1484 | 1484 | self.shdr_table_dirty = false; |
| 1485 | 1485 | } |
| 1486 | 1486 | 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", .{}); | |
| 1488 | 1488 | self.error_flags.no_entry_point_found = true; |
| 1489 | 1489 | } else { |
| 1490 | log.debug(.link, "flushing. no_entry_point_found = false\n", .{}); | |
| 1490 | log.debug("flushing. no_entry_point_found = false\n", .{}); | |
| 1491 | 1491 | self.error_flags.no_entry_point_found = false; |
| 1492 | 1492 | try self.writeElfHeader(); |
| 1493 | 1493 | } |
| ... | ... | @@ -1816,10 +1816,10 @@ pub const File = struct { |
| 1816 | 1816 | try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1); |
| 1817 | 1817 | |
| 1818 | 1818 | 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 }); | |
| 1820 | 1820 | decl.link.elf.local_sym_index = i; |
| 1821 | 1821 | } 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 }); | |
| 1823 | 1823 | decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len); |
| 1824 | 1824 | _ = self.local_symbols.addOneAssumeCapacity(); |
| 1825 | 1825 | } |
| ... | ... | @@ -2016,11 +2016,11 @@ pub const File = struct { |
| 2016 | 2016 | !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment); |
| 2017 | 2017 | if (need_realloc) { |
| 2018 | 2018 | 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 }); | |
| 2020 | 2020 | if (vaddr != local_sym.st_value) { |
| 2021 | 2021 | local_sym.st_value = vaddr; |
| 2022 | 2022 | |
| 2023 | log.debug(.link, " (writing new offset table entry)\n", .{}); | |
| 2023 | log.debug(" (writing new offset table entry)\n", .{}); | |
| 2024 | 2024 | self.offset_table.items[decl.link.elf.offset_table_index] = vaddr; |
| 2025 | 2025 | try self.writeOffsetTableEntry(decl.link.elf.offset_table_index); |
| 2026 | 2026 | } |
| ... | ... | @@ -2038,7 +2038,7 @@ pub const File = struct { |
| 2038 | 2038 | const decl_name = mem.spanZ(decl.name); |
| 2039 | 2039 | const name_str_index = try self.makeString(decl_name); |
| 2040 | 2040 | 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 }); | |
| 2042 | 2042 | errdefer self.freeTextBlock(&decl.link.elf); |
| 2043 | 2043 | |
| 2044 | 2044 | local_sym.* = .{ |
| ... | ... | @@ -2148,7 +2148,7 @@ pub const File = struct { |
| 2148 | 2148 | if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) { |
| 2149 | 2149 | const new_offset = self.findFreeSpace(needed_size, 1); |
| 2150 | 2150 | 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", .{ | |
| 2152 | 2152 | existing_size, |
| 2153 | 2153 | debug_line_sect.sh_offset, |
| 2154 | 2154 | new_offset, |
| ... | ... | @@ -2227,7 +2227,7 @@ pub const File = struct { |
| 2227 | 2227 | try dbg_info_buffer.writer().print("{}\x00", .{ty}); |
| 2228 | 2228 | }, |
| 2229 | 2229 | 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}); | |
| 2231 | 2231 | try dbg_info_buffer.append(abbrev_pad1); |
| 2232 | 2232 | }, |
| 2233 | 2233 | } |
| ... | ... | @@ -2299,7 +2299,7 @@ pub const File = struct { |
| 2299 | 2299 | if (needed_size > self.allocatedSize(debug_info_sect.sh_offset)) { |
| 2300 | 2300 | const new_offset = self.findFreeSpace(needed_size, 1); |
| 2301 | 2301 | 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", .{ | |
| 2303 | 2303 | existing_size, |
| 2304 | 2304 | debug_info_sect.sh_offset, |
| 2305 | 2305 | new_offset, |
src-self-hosted/liveness.zig+1-1| ... | ... | @@ -151,5 +151,5 @@ fn analyzeInst( |
| 151 | 151 | @panic("Handle liveness analysis for instructions with many parameters"); |
| 152 | 152 | } |
| 153 | 153 | |
| 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 }); | |
| 155 | 155 | } |
src-self-hosted/main.zig+1-1| ... | ... | @@ -557,7 +557,7 @@ fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !vo |
| 557 | 557 | }); |
| 558 | 558 | } |
| 559 | 559 | } 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}); | |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | if (zir_out_path) |zop| { |