Browse Source

console.debug() should use a debug Logger method (#4019)

pull/4026/head
Hans Larsen 3 weeks ago committed by GitHub
parent
commit
d3dbb4ad02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      core/runtime/src/console/mod.rs

10
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<JsValue> {
logger.log(formatter(args, context)?, &console.state, context)?;
logger.debug(formatter(args, context)?, &console.state, context)?;
Ok(JsValue::undefined())
}

Loading…
Cancel
Save