Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion core/runtime/src/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -473,7 +481,7 @@ impl Console {
logger: &impl Logger,
context: &mut Context,
) -> JsResult<JsValue> {
logger.log(formatter(args, context)?, &console.state, context)?;
logger.debug(formatter(args, context)?, &console.state, context)?;
Ok(JsValue::undefined())
}

Expand Down