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()) }