(init) botlog module

This commit is contained in:
ModulatingForce 2024-02-13 07:54:35 -05:00
commit eb6c5ec58c
8 changed files with 382 additions and 68 deletions

View file

@ -7,15 +7,23 @@ use std::process::Output;
use crate::core::botinstance::ArcBox;
use crate::core::botinstance::BotInstance;
use casual_logger::Extension;
use tokio::sync::RwLock;
use std::sync::Arc;
pub type BotAR = Arc<RwLock<BotInstance>>;
use casual_logger::{Level,Log};
#[tokio::main]
pub async fn main() {
Log::set_file_ext(Extension::Log);
Log::set_level(Level::Trace);
// Log::set_level(Level::Notice);
let bot = BotInstance::init().await;
Log::debug("Checking bot actions");
let a = Arc::clone(&bot.botmodules.botactions);
let a = a.read().await;
// let a = *a;
@ -23,18 +31,32 @@ pub async fn main() {
for (_,acts) in &*a {
for act in acts {
match act {
crate::core::botmodules::BotAction::C(b) => println!("bot actiions: {}",b.command),
crate::core::botmodules::BotAction::L(l) => println!("bot actiions: {}",l.name),
_ => println!("Not a valid match??"),
crate::core::botmodules::BotAction::C(b) => {
// println!("bot actiions: {}",b.command)
Log::info(&format!("bot actions: {}",b.command));
},
crate::core::botmodules::BotAction::L(l) => {
// println!("bot actiions: {}",l.name)
Log::info(&format!("bot actions: {}",l.name));
},
_ => {
// println!("Not a valid match??")
Log::info("Not a valid match??");
},
}
}
};
println!("Starting runner..");
// println!("Starting runner..");
Log::notice("Starting Bot Runner");
Log::flush();
bot.runner().await;
println!("ERROR : EXIT Game loop");
// println!("ERROR : EXIT Game loop");
// let msg = Log::fatal("ERROR : EXIT Game loop");
panic!("{}",Log::fatal("ERROR : EXIT Game loop"));
}