bindings: make messageWithTypeAndLevel a ConsoleObject method

This commit is contained in:
Meghan Denny
2024-10-24 20:32:09 -07:00
parent 868aa95ec2
commit fdb6ef0efa
2 changed files with 3 additions and 7 deletions

View File

@@ -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

View File

@@ -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,