diff options
Diffstat (limited to 'src/logger.zig')
-rw-r--r-- | src/logger.zig | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/logger.zig b/src/logger.zig index 7340efc3d..dfe60e2af 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -1027,6 +1027,20 @@ pub const Log = struct { }); } + pub fn addZigErrorWithNote(log: *Log, allocator: std.mem.Allocator, err: anyerror, comptime noteFmt: string, args: anytype) !void { + @setCold(true); + log.errors += 1; + + var notes = try allocator.alloc(Data, 1); + notes[0] = rangeData(null, Range.None, allocPrint(allocator, noteFmt, args) catch unreachable); + + try log.addMsg(.{ + .kind = .err, + .data = rangeData(null, Range.None, @errorName(err)), + .notes = notes, + }); + } + pub fn addRangeWarning(log: *Log, source: ?*const Source, r: Range, text: string) !void { @setCold(true); if (!Kind.shouldPrint(.warn, log.level)) return; @@ -1092,6 +1106,21 @@ pub const Log = struct { }); } + pub fn addWarningWithNote(log: *Log, source: ?*const Source, l: Loc, allocator: std.mem.Allocator, warn: string, comptime note_fmt: string, note_args: anytype) !void { + @setCold(true); + if (!Kind.shouldPrint(.warn, log.level)) return; + log.warnings += 1; + + var notes = try allocator.alloc(Data, 1); + notes[0] = rangeData(source, Range{ .loc = l }, allocPrint(allocator, note_fmt, note_args) catch unreachable); + + try log.addMsg(.{ + .kind = .warn, + .data = rangeData(null, Range.None, warn), + .notes = notes, + }); + } + pub fn addRangeDebug(log: *Log, source: ?*const Source, r: Range, text: string) !void { @setCold(true); if (!Kind.shouldPrint(.debug, log.level)) return; |