wasm-logger
A logger that sends a message with its Rust source's line and filename to the browser console.
In v0.1.4 and up, the default Config will put the message on the same line as other info (see more). If you want them on a separate line as the screenshot above, you must config like this:
;
init
Usage
Note: For more information about how to use loggers in Rust, see log.
Cargo.toml
[dependencies]
log = "0.4.6"
wasm-logger = "0.1.5"
Initialize wasm-logger
when your app start:
;
// Logging
info!;
error!;
init
Log for a specific module only
You can provide a path prefix:
;
init
then, wasm-logger
only logs message from some::module
Mapping from log
to console's methods
log::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!
toconsole.log
log::trace!
toconsole.debug
.
Note for Chromium/Chrome users
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.
License
MIT or Apache-2.0