Crates.io | wasm-logger |
lib.rs | wasm-logger |
version | 0.2.0 |
source | src |
created_at | 2018-10-04 03:28:43.960014 |
updated_at | 2019-11-15 09:17:07.774463 |
description | A logger that sends a message with its Rust source's line and filename to the browser console |
homepage | |
repository | https://gitlab.com/limira-rs/wasm-logger |
max_upload_size | |
id | 87929 |
size | 21,981 |
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-logger = "0.2.0"
Initialize wasm-logger
when your app start:
wasm_logger::init(wasm_logger::Config::default());
// Logging
log::info!("Some info");
log::error!("Error message");
You can provide a path prefix:
wasm_logger::init(wasm_logger::Config::default().module_prefix("some::module"));
then, wasm-logger
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.log
log::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