From d3dbb4ad02d395457843317a7dc67e0dd0195178 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Sat, 2 Nov 2024 08:49:22 -0700 Subject: [PATCH] console.debug() should use a debug Logger method (#4019) --- core/runtime/src/console/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/runtime/src/console/mod.rs b/core/runtime/src/console/mod.rs index c9fde6b79d..d63bb1613a 100644 --- a/core/runtime/src/console/mod.rs +++ b/core/runtime/src/console/mod.rs @@ -28,6 +28,14 @@ use std::{cell::RefCell, collections::hash_map::Entry, io::Write, rc::Rc, time:: /// A trait that can be used to forward console logs to an implementation. pub trait Logger: Trace + Sized { + /// Log a debug message (`console.debug`). By default, passes the message to `log`. + /// + /// # Errors + /// Returning an error will throw an exception in JavaScript. + fn debug(&self, msg: String, state: &ConsoleState, context: &mut Context) -> JsResult<()> { + self.log(msg, state, context) + } + /// Log a log message (`console.log`). /// /// # Errors @@ -473,7 +481,7 @@ impl Console { logger: &impl Logger, context: &mut Context, ) -> JsResult { - logger.log(formatter(args, context)?, &console.state, context)?; + logger.debug(formatter(args, context)?, &console.state, context)?; Ok(JsValue::undefined()) }