#logger #bindgen #console #web #log #logging #wasm-bindgen #backend #utility #message

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

#1027 in WebAssembly

Download history 153/week @ 2023-01-30 229/week @ 2023-02-06 115/week @ 2023-02-13 96/week @ 2023-02-20 97/week @ 2023-02-27 199/week @ 2023-03-06 174/week @ 2023-03-13 137/week @ 2023-03-20 183/week @ 2023-03-27 100/week @ 2023-04-03 109/week @ 2023-04-10 34/week @ 2023-04-17 140/week @ 2023-04-24 126/week @ 2023-05-01 167/week @ 2023-05-08 107/week @ 2023-05-15

540 downloads per month
Used in keyplace

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

~1–1.5MB
~32K SLoC