#wasm-bindgen #log #console #message #web #browser #send

wasm-bindgen-console-logger

A simple backend for the log crate that sends messages to the Web browser's console

2 releases

0.1.1 Jan 24, 2019
0.1.0 Jan 1, 2019

#725 in Debugging

Download history 541/week @ 2024-07-28 432/week @ 2024-08-04 334/week @ 2024-08-11 397/week @ 2024-08-18 419/week @ 2024-08-25 671/week @ 2024-09-01 456/week @ 2024-09-08 529/week @ 2024-09-15 430/week @ 2024-09-22 278/week @ 2024-09-29 228/week @ 2024-10-06 254/week @ 2024-10-13 525/week @ 2024-10-20 390/week @ 2024-10-27 439/week @ 2024-11-03 400/week @ 2024-11-10

1,767 downloads per month
Used in 2 crates

CC0 license

6KB
56 lines

wasm-bindgen-console-logger

This small utility crate integrates the log crate with the JavaScript console logging functions with the help of wasm-bindgen.

Example

use log::{error, info, warn};
use wasm_bindgen::prelude::*;
use wasm_bindgen_console_logger::DEFAULT_LOGGER;

#[wasm_bindgen]
pub fn start() {
    log::set_logger(&DEFAULT_LOGGER).unwrap();
    log::set_max_level(log::LevelFilter::Info);

    error!("Error message");
    warn!("Warning message");
    info!("Informational message");
}

By sheer coincidence, this crate was published at almost exactly the same time as console_log. Assuming that it receives continued maintenance, console_log may end up being the "go-to" option for logging in WebAssembly applications, but I'm planning to provide at least basic maintenance on this crate until the situation becomes clearer.

Dependencies

~0.7–1.3MB
~27K SLoC