Crates.io | weblog |
lib.rs | weblog |
version | 0.4.0-beta.1 |
source | src |
created_at | 2020-09-15 11:16:28.232583 |
updated_at | 2020-11-13 09:24:32.382178 |
description | weblog is a crate that defines a set of macros for calling `console.log()` and other members of the browser's console API when targeting Wasm. |
homepage | |
repository | https://git.netflux.io/rob/weblog |
max_upload_size | |
id | 288965 |
size | 18,452 |
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.
web-sys
and stdweb
backends with an identical public APIA simple example.
console_log!("Hello world!");
Passing multiple arguments is fine too.
console_log!("Foo", "bar", "baz");
All of the common browser log levels are supported.
console_debug!("Just testing...");
console_warn!("...but then...");
console_error!("...something bad happened.");
It's possible to send more than just strings or &str
s:
console_log!(
"&str",
"string".to_string(),
1,
2.0,
3f32,
true,
false
);
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!
# Defaults to web-sys
weblog = "0.3.0"
# For stdweb:
weblog = { version = "0.3.0", default-features = false, features = ["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!
Licensed under MIT or Apache-2.