feat: add basic logging
This commit is contained in:
41
src/scripting/logging.rs
Normal file
41
src/scripting/logging.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use mlua::{Lua, Result, Table};
|
||||
|
||||
pub fn init(lua: &Lua, globals: &Table) -> Result<()> {
|
||||
globals.set(
|
||||
"error",
|
||||
lua.create_function(|_, message: String| {
|
||||
error!("{message}");
|
||||
Ok(())
|
||||
})?,
|
||||
)?;
|
||||
globals.set(
|
||||
"warn",
|
||||
lua.create_function(|_, message: String| {
|
||||
warn!("{message}");
|
||||
Ok(())
|
||||
})?,
|
||||
)?;
|
||||
globals.set(
|
||||
"info",
|
||||
lua.create_function(|_, message: String| {
|
||||
info!("{message}");
|
||||
Ok(())
|
||||
})?,
|
||||
)?;
|
||||
globals.set(
|
||||
"debug",
|
||||
lua.create_function(|_, message: String| {
|
||||
debug!("{message}");
|
||||
Ok(())
|
||||
})?,
|
||||
)?;
|
||||
globals.set(
|
||||
"trace",
|
||||
lua.create_function(|_, message: String| {
|
||||
trace!("{message}");
|
||||
Ok(())
|
||||
})?,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
pub mod client;
|
||||
pub mod logging;
|
||||
pub mod position;
|
||||
|
||||
Reference in New Issue
Block a user