1use std::cell::RefCell;
2
3thread_local! {
4 static PLUGIN_LOG: RefCell<Vec<String>> = const { RefCell::new(Vec::new()) };
5}
6
7pub fn cradle_log(msg: &str) {
9 PLUGIN_LOG.with(|log| {
10 log.borrow_mut().push(msg.to_string());
11 });
12}
13
14pub fn drain_log() -> Vec<String> {
16 PLUGIN_LOG.with(|log| log.borrow_mut().drain(..).collect())
17}
18
19#[macro_export]
21macro_rules! clog {
22 ($($arg:tt)*) => {
23 $crate::cradle_log(&format!($($arg)*))
24 };
25}
26
27#[macro_export]
29macro_rules! plog {
30 ($plugin:expr, $($arg:tt)*) => {
31 $crate::cradle_log(&format!("[{}] {}", $plugin.name(), format!($($arg)*)))
32 };
33}