From fdb6ef0efab96e0eec43c355f3a640dbaaf5c13d Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 24 Oct 2024 20:32:09 -0700 Subject: [PATCH] bindings: make messageWithTypeAndLevel a ConsoleObject method --- src/bun.js/ConsoleObject.zig | 7 ++----- src/bun.js/bindings/bindings.zig | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/bun.js/ConsoleObject.zig b/src/bun.js/ConsoleObject.zig index e037f8ccc0..5158b1d0b9 100644 --- a/src/bun.js/ConsoleObject.zig +++ b/src/bun.js/ConsoleObject.zig @@ -79,8 +79,7 @@ threadlocal var stdout_lock_count: u16 = 0; /// https://console.spec.whatwg.org/#formatter pub fn messageWithTypeAndLevel( - //console_: ConsoleObject.Type, - _: ConsoleObject.Type, + console: *ConsoleObject, message_type: MessageType, //message_level: u32, level: MessageLevel, @@ -92,8 +91,6 @@ pub fn messageWithTypeAndLevel( return; } - var console = global.bunVM().console; - // Lock/unlock a mutex incase two JS threads are console.log'ing at the same time // We do this the slightly annoying way to avoid assigning a pointer if (level == .Warning or level == .Error or message_type == .Assert) { @@ -3439,7 +3436,7 @@ pub fn takeHeapSnapshot( ) callconv(JSC.conv) void { // TODO: this does an extra JSONStringify and we don't need it to! var snapshot: [1]JSValue = .{globalThis.generateHeapSnapshot()}; - ConsoleObject.messageWithTypeAndLevel(undefined, MessageType.Log, MessageLevel.Debug, globalThis, &snapshot, 1); + globalThis.bunVM().console.messageWithTypeAndLevel(.Log, .Debug, globalThis, &snapshot, 1); } pub fn timeStamp( // console diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index d13e3256aa..49a9358683 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -4597,8 +4597,7 @@ pub const JSValue = enum(JSValueReprInt) { message_type: ConsoleObject.MessageType, message_level: ConsoleObject.MessageLevel, ) void { - JSC.ConsoleObject.messageWithTypeAndLevel( - undefined, + globalObject.bunVM().console.messageWithTypeAndLevel( message_type, message_level, globalObject,