#wasm-bindgen #log #console #message #web #browser #back-end

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

#586 in Debugging

Download history 607/week @ 2023-12-13 348/week @ 2023-12-20 140/week @ 2023-12-27 479/week @ 2024-01-03 403/week @ 2024-01-10 954/week @ 2024-01-17 629/week @ 2024-01-24 923/week @ 2024-01-31 771/week @ 2024-02-07 711/week @ 2024-02-14 1224/week @ 2024-02-21 841/week @ 2024-02-28 535/week @ 2024-03-06 702/week @ 2024-03-13 766/week @ 2024-03-20 414/week @ 2024-03-27

2,571 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.8–1.4MB
~29K SLoC