diff options
author | 2021-12-16 02:42:09 -0800 | |
---|---|---|
committer | 2021-12-16 02:42:09 -0800 | |
commit | dd7659c643778655a54ebce79b813becf1f2174c (patch) | |
tree | 5702e2f4206d9a2457fe7d0b13cb1046bdf49c80 | |
parent | aed6f89772d0d07ac0c4d5b8cb5324d5dc7246b4 (diff) | |
download | bun-dd7659c643778655a54ebce79b813becf1f2174c.tar.gz bun-dd7659c643778655a54ebce79b813becf1f2174c.tar.zst bun-dd7659c643778655a54ebce79b813becf1f2174c.zip |
Print errors below warnings
-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; + } } } |