| Crates.io | wasm-log |
| lib.rs | wasm-log |
| version | 0.3.1 |
| created_at | 2022-11-25 10:34:44.793491+00 |
| updated_at | 2022-11-25 11:19:48.331145+00 |
| description | A logger that sends a message with its Rust source's line and filename to the browser console |
| homepage | |
| repository | https://github.com/s1gtrap/wasm-log |
| max_upload_size | |
| id | 722661 |
| size | 33,916 |
A logger that sends a message with its Rust source's line and filename to the browser console.

Note: For more information about how to use loggers in Rust, see log.
Cargo.toml
[dependencies]
log = "0.4.6"
wasm-log = "0.3"
Initialize wasm-log when your app start:
wasm-log::init(wasm-log::Config::default());
// Logging
log::info!("Some info");
log::error!("Error message");
You can provide a path prefix:
wasm-log::init(wasm-log::Config::default().module_prefix("some::module"));
then, wasm-log only logs message from some::module
log to console's methodslog::error!, log::warn! and log::info! call theirs equivalent methods of the browser console. The console.trace method outputs some extra trace from the generated JS glue code which we don't want. Therefore, we choose to map:
log::debug! to console.loglog::trace! to console.debug.Chromium/Chrome filters out console.debug (execute by log::trace!) by default. You must check the Verbose filter in your browser console to see trace entries.
MIT or Apache-2.0