Be advised that this crate is still considered experimental however should be stable for use in its current state.
Getting started
You can start using log4wasm by adding the following in your Cargo.toml [dependencies] section:
= "0.1.3"
Note: log4wasm relies on the wasm-bindgen crate for code-generation therefore it is the current recommended approach for building reliably.
Example
A minimal use-case within your application would look something like the following:
log4wasm provides a suite of macros out of the box available for use. These may be favorable in instances where building a custom logger is not necessary.
trace!;
debug!;
info!;
warning!;
error!;
fatal!;
Alternatively, custom loggers may be created using the designated builder:
use ;
use ;
// Create a custom logger with a desired name and log level.
let logger = new_builder
.named
.with_level
.build;
// Create a styling to be applied on the output written to console.
let styled_log = with_content
.colored
.decorate
.into_log;
// Write the styled output to console.
logger.print_fmt;