文件
mynode/packages/onenote-converter/parser-utils/src/log.rs
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

57 行
1.4 KiB
Rust

use std::sync::Mutex;
use lazy_static::lazy_static;
#[macro_export]
#[cfg(target_arch = "wasm32")]
macro_rules! log {
( $( $t:tt )* ) => {
#[cfg(debug_assertions)]
web_sys::console::log_2(&format!("OneNoteConverter: ").into(), &format!( $( $t )* ).into());
}
}
#[macro_export]
#[cfg(target_arch = "wasm32")]
macro_rules! log_warn {
( $( $t:tt )* ) => {
use parser_utils::log::get_current_page;
web_sys::console::warn_1(&format!("OneNoteConverter: Warning around the following page: {}", get_current_page()).into());
web_sys::console::warn_2(&format!("OneNoteConverter: ").into(), &format!( $( $t )* ).into());
}
}
#[macro_export]
#[cfg(not(target_arch = "wasm32"))]
macro_rules! log {
( $( $t:tt )* ) => {
#[cfg(debug_assertions)]
println!( $( $t )* );
}
}
#[macro_export]
#[cfg(not(target_arch = "wasm32"))]
macro_rules! log_warn {
( $( $t:tt )* ) => {
println!("Warning: {}, near {}", &format!( $( $t )* ), parser_utils::log::get_current_page());
}
}
lazy_static! {
static ref CURRENT_PAGE: Mutex<Option<String>> = Mutex::new(None);
}
pub fn set_current_page(page_name: String) {
let mut current_page = CURRENT_PAGE.lock().unwrap();
*current_page = Some(page_name.to_string());
}
pub fn get_current_page() -> String {
let current_page = CURRENT_PAGE.lock().unwrap();
current_page
.clone()
.unwrap_or_else(|| String::from("[None]"))
}