yazi/yazi-plugin/src/utils/log.rs
2024-11-13 11:38:11 +08:00

20 lines
550 B
Rust

use mlua::{Function, Lua, MultiValue};
use tracing::{debug, error};
use super::Utils;
impl Utils {
pub(super) fn dbg(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|_, values: MultiValue| {
let s = values.into_iter().map(|v| format!("{v:#?}")).collect::<Vec<_>>().join(" ");
Ok(debug!("{s}"))
})
}
pub(super) fn err(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|_, values: MultiValue| {
let s = values.into_iter().map(|v| format!("{v:#?}")).collect::<Vec<_>>().join(" ");
Ok(error!("{s}"))
})
}
}