Skip to content

Commit

Permalink
console.debug() should use a debug Logger method (#4019)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl authored Nov 2, 2024
1 parent 23e8ba2 commit d3dbb4a
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit d3dbb4a

Please sign in to comment.