diff options
| author | 2023-05-06 13:18:13 -0700 | |
|---|---|---|
| committer | 2023-05-06 13:18:13 -0700 | |
| commit | 01ce690a0105ac8c9d3c15691e43f7555fc33b53 (patch) | |
| tree | 17c8ad59dcbb2578d313a36d61d9472adf2fa564 | |
| parent | 1da75791dae29ec10209c76e71b4f604471dabc8 (diff) | |
| download | bun-01ce690a0105ac8c9d3c15691e43f7555fc33b53.tar.gz bun-01ce690a0105ac8c9d3c15691e43f7555fc33b53.tar.zst bun-01ce690a0105ac8c9d3c15691e43f7555fc33b53.zip | |
Clone the logs more
| -rw-r--r-- | src/bundler/bundle_v2.zig | 6 | ||||
| -rw-r--r-- | src/logger.zig | 13 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 173d1c247..95595e4fb 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -1735,7 +1735,7 @@ pub const BundleV2 = struct { } }, .success => |*result| { - result.log.appendTo(this.bundler.log) catch unreachable; + result.log.cloneToWithRecycled(this.bundler.log, true) catch unreachable; { // to minimize contention, we add watcher here @@ -1875,12 +1875,12 @@ pub const BundleV2 = struct { } if (err.log.msgs.items.len > 0) { - err.log.appendTo(this.bundler.log) catch unreachable; + err.log.cloneToWithRecycled(this.bundler.log, true) catch unreachable; } else { this.bundler.log.addErrorFmt( null, Logger.Loc.Empty, - this.bundler.allocator, + bun.default_allocator, "{s} while {s}", .{ @errorName(err.err), @tagName(err.step) }, ) catch unreachable; diff --git a/src/logger.zig b/src/logger.zig index da7f1e572..ac8acd7f7 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -729,7 +729,7 @@ pub const Log = struct { } } - pub fn appendTo(self: *Log, other: *Log) !void { + pub fn cloneTo(self: *Log, other: *Log) !void { var notes_count: usize = 0; for (self.msgs.items) |msg_| { @@ -759,10 +759,14 @@ pub const Log = struct { try other.msgs.appendSlice(self.msgs.items); other.warnings += self.warnings; other.errors += self.errors; - self.msgs.deinit(); } - pub fn appendToWithRecycled(self: *Log, other: *Log, recycled: bool) !void { + pub fn appendTo(self: *Log, other: *Log) !void { + try self.cloneTo(other); + self.msgs.clearAndFree(); + } + + pub fn cloneToWithRecycled(self: *Log, other: *Log, recycled: bool) !void { try other.msgs.appendSlice(self.msgs.items); other.warnings += self.warnings; other.errors += self.errors; @@ -805,7 +809,10 @@ pub const Log = struct { } } } + } + pub fn appendToWithRecycled(self: *Log, other: *Log, recycled: bool) !void { + try self.cloneToWithRecycled(other, recycled); self.msgs.clearAndFree(); } |
