Trait quick_js::console::ConsoleBackend[][src]

pub trait ConsoleBackend: RefUnwindSafe + 'static {
    fn log(&self, level: Level, values: Vec<JsValue>);
}

A console backend that handles console messages sent from JS via console.{log,debug,trace,…} functions.

A backend has to be registered via the ContextBuilder::console method.

A backend that forwads to the log crate is available with the log feature.

Note that any closure of type Fn(Level, Vec<JsValue>) implements this trait.

A very simple logger that just prints to stderr could look like this:

use quick_js::{Context, JsValue, console::Level};

Context::builder()
    .console(|level: Level, args: Vec<JsValue>| {
        eprintln!("{}: {:?}", level, args);
    })
    .build()

Required methods

fn log(&self, level: Level, values: Vec<JsValue>)[src]

Handle a log message.

Loading content...

Implementors

impl ConsoleBackend for LogConsole[src]

impl<F> ConsoleBackend for F where
    F: Fn(Level, Vec<JsValue>) + RefUnwindSafe + 'static, 
[src]

Loading content...