loro/crates/loro-wasm/src/log.rs

27 lines
775 B
Rust

use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
extern "C" {
// Use `js_namespace` here to bind `console.log(..)` instead of just
// `log(..)`
#[wasm_bindgen(js_namespace = console)]
pub fn log(s: &str);
#[wasm_bindgen(js_namespace = console)]
pub fn error(s: &str);
}
/// Console log macro.
#[macro_export]
macro_rules! console_log {
// Note that this is using the `log` function imported above during
// `bare_bones`
($($t:tt)*) => ($crate::log::log(&format_args!($($t)*).to_string()))
}
/// Console log macro.
#[macro_export]
macro_rules! console_error {
// Note that this is using the `log` function imported above during
// `bare_bones`
($($t:tt)*) => ($crate::log::error(&format_args!($($t)*).to_string()))
}