1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
//! 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-sys` and `stdweb` backends 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. //! //! ``` //! # #[macro_use] extern crate weblog; //! # fn main() { //! console_log!("Hello world!"); //! # } //! ``` //! Passing multiple arguments is fine too. //! //! ``` //! # #[macro_use] extern crate weblog; //! # fn main() { //! console_log!("Foo", "bar", "baz"); //! # } //! ``` //! All of the common browser log levels are supported. //! //! ``` //! # #[macro_use] extern crate weblog; //! # fn main() { //! 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: //! //! ``` //! # #[macro_use] extern crate weblog; //! # fn main() { //! console_log!( //! "&str", //! "string".to_string(), //! 1, //! 2.0, //! 3f32, //! true, //! false, //! Some("option"), //! ); //! # } //! ``` //! When using `web-sys` crate the macros accept any value that implements the `Into<JsValue>` trait. See [JsValue](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html) for //! more details. //! //! No stringification is performed on the Rust side - so objects will be fully introspectable in //! the browser's console! //! //! # Usage //! //! By default, the crate assumes the presence of the `web-sys` crate. //! //! ```toml //! weblog = "0.3" //! ``` //! //! //! If you'd prefer to use it //! with `stdweb`, enable the feature in `Cargo.toml`: //! //! ```toml //! weblog = { version = "0.3", default-features = false, features = ["stdweb"] } //! ``` //! mod console; #[cfg(feature = "web_sys")] pub use weblog_proc_macro::*; #[cfg(feature = "web_sys")] pub use ::web_sys; #[cfg(feature = "std_web")] pub use self::console::std_web::*;