|
|
@ -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.
|
|
|
|
/// A trait that can be used to forward console logs to an implementation.
|
|
|
|
pub trait Logger: Trace + Sized { |
|
|
|
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`).
|
|
|
|
/// Log a log message (`console.log`).
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// # Errors
|
|
|
|
/// # Errors
|
|
|
@ -473,7 +481,7 @@ impl Console { |
|
|
|
logger: &impl Logger, |
|
|
|
logger: &impl Logger, |
|
|
|
context: &mut Context, |
|
|
|
context: &mut Context, |
|
|
|
) -> JsResult<JsValue> { |
|
|
|
) -> JsResult<JsValue> { |
|
|
|
logger.log(formatter(args, context)?, &console.state, context)?; |
|
|
|
logger.debug(formatter(args, context)?, &console.state, context)?; |
|
|
|
Ok(JsValue::undefined()) |
|
|
|
Ok(JsValue::undefined()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|