diff options
-rw-r--r-- | src/logger.zig | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/logger.zig b/src/logger.zig index b9d2b62ec..c2386ddb2 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -858,10 +858,37 @@ pub const Log = struct { pub fn printForLogLevelWithEnableAnsiColors(self: *Log, to: anytype, comptime enable_ansi_colors: bool) !void { var printed = false; - for (self.msgs.items) |msg| { - if (msg.kind.shouldPrint(self.level)) { - try msg.writeFormat(to, enable_ansi_colors); - printed = true; + + if (self.warnings > 0 and self.errors > 0) { + // Print warnings at the top + // errors at the bottom + // This is so if you're reading from a terminal + // and there are a bunch of warnings + // You can more easily see where the errors are + + for (self.msgs.items) |msg| { + if (msg.kind != .err) { + if (msg.kind.shouldPrint(self.level)) { + try msg.writeFormat(to, enable_ansi_colors); + printed = true; + } + } + } + + for (self.msgs.items) |msg| { + if (msg.kind == .err) { + if (msg.kind.shouldPrint(self.level)) { + try msg.writeFormat(to, enable_ansi_colors); + printed = true; + } + } + } + } else { + for (self.msgs.items) |msg| { + if (msg.kind.shouldPrint(self.level)) { + try msg.writeFormat(to, enable_ansi_colors); + printed = true; + } } } |