Weblog
weblog is a crate that defines a set of macros for calling console.log(), console.error() and other members of the browser's console API when targeting Wasm.
Features
- Supports
web-sysandstdwebbackends with an identical public API - Support for variadic arguments on all calls
- No stringification before sending to the browser - log entire objects and use the full introspective debugging power of the browser console.
Examples
A simple example.
console_log!;
Passing multiple arguments is fine too.
console_log!;
All of the common browser log levels are supported.
console_debug!;
console_warn!;
console_error!;
It's possible to send more than just strings or &strs:
console_log!;
When using web-sys crate the macros accept any value that implements the Into<JsValue> trait. See JsValue for
more details.
No stringification is performed on the Rust side - so objects will be fully introspectable in the browser's console!
Usage
# Defaults to web-sys
= "0.3.0"
# For stdweb:
= { = "0.3.0", = false, = ["std_web"] }
See the documentation for usage examples.
The crate currently exposes the following macros:
console_assert!console_clear!console_count!console_count_reset!console_debug!console_dir!console_dirxml!console_error!console_exception!console_info!console_log!console_table!console_time!console_time_end!console_time_stamp!console_trace!console_warn!
License
Licensed under MIT or Apache-2.