Better logging with plugin fix
This commit is contained in:
@@ -1 +1,3 @@
|
||||
/target
|
||||
/plugins
|
||||
config.json
|
||||
Generated
+7
@@ -20,6 +20,12 @@ version = "2.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.101"
|
||||
@@ -105,6 +111,7 @@ name = "voxa-server"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
use voxa_server::{export_plugin, plugin::Plugin};
|
||||
use voxa_server::{export_plugin, logger, plugin::Plugin};
|
||||
|
||||
logger! {
|
||||
const LOGGER "My Plugin"
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MyPlugin;
|
||||
|
||||
impl Plugin for MyPlugin {
|
||||
fn init(&mut self) {
|
||||
println!("MyPlugin initialized!");
|
||||
LOGGER.info("MyPlugin initialized!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-5
@@ -1,9 +1,14 @@
|
||||
use std::path::PathBuf;
|
||||
use voxa_server::plugin::PluginInstance;
|
||||
|
||||
use voxa_server::{ServerConfig, plugin::PluginInstance, vfs};
|
||||
|
||||
fn main() -> voxa_server::Result<()> {
|
||||
let root = PathBuf::from("../");
|
||||
let config = voxa_server::ServerConfig::default();
|
||||
let plugin = test_plugin::MyPlugin::default();
|
||||
config.start_with(vec![PluginInstance::Static(Box::new(plugin))], &root)
|
||||
let root = PathBuf::from("./");
|
||||
let config: ServerConfig = vfs::read_config(&root.join("config.json"))?;
|
||||
let mut server = config.build(&root);
|
||||
server.add_plugin(PluginInstance::Static(Box::new(
|
||||
test_plugin::MyPlugin::default(),
|
||||
)));
|
||||
server.run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user