https://github.com/blm768/wasm-bindgen-console-logger
Integrates the Rust log crate with the Web console
https://github.com/blm768/wasm-bindgen-console-logger
Last synced: about 2 months ago
JSON representation
Integrates the Rust log crate with the Web console
- Host: GitHub
- URL: https://github.com/blm768/wasm-bindgen-console-logger
- Owner: blm768
- License: other
- Created: 2019-01-01T01:36:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-24T06:32:47.000Z (over 7 years ago)
- Last Synced: 2025-12-14T01:54:19.371Z (6 months ago)
- Language: Rust
- Homepage:
- Size: 7.81 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `wasm-bindgen-console-logger`
This small utility crate integrates the [`log`](https://crates.io/crates/log)
crate with the JavaScript console logging functions with the help of
[`wasm-bindgen`](https://crates.io/crates/wasm-bindgen).
## Example
```rust
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");
}
```
## Related libraries
By sheer coincidence, this crate was published at almost exactly the same
time as [`console_log`](https://crates.io/crates/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.