Log Size Review #35

Merged
modulatingforce merged 4 commits from logsize_review into main 2024-03-20 21:00:56 -04:00
2 changed files with 24 additions and 0 deletions
Showing only changes of commit 7d8672913a - Show all commits

View file

@ -4,6 +4,7 @@ use std::sync::Arc;
use tokio::sync::mpsc::UnboundedReceiver;
use tokio::sync::{Mutex, RwLock};
use tokio::time::{sleep, Duration};
use twitch_irc::login::StaticLoginCredentials;
use twitch_irc::message::{PrivmsgMessage, ServerMessage};
@ -23,6 +24,7 @@ use crate::core::identity::{ChangeResult, IdentityManager, Permissible};
use crate::core::botlog;
use crate::core::chat::Chat;
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum ChType {
Channel(String),
@ -109,6 +111,19 @@ impl BotInstance {
ratelimiters.insert(Channel(String::from(chnl)), n);
}
tokio::spawn(async {
loop {
let routine_mins = 60 * 60 * 24 * 1 ; // Every 1 Day
// let routine_mins = 1; // Every 1 Minute
Log::remove_old_logs();
Log::info(&format!("Internal Purge Routine Triggered - running every {} mins",routine_mins));
Log::flush();
sleep(Duration::from_secs(60 * routine_mins)).await
}
});
BotInstance {
prefix,
bot_channel: Channel(login_name),
@ -130,6 +145,7 @@ impl BotInstance {
let mut msglock = botlock.incoming_messages.write().await;
while let Some(message) = msglock.recv().await {
match message {
ServerMessage::Notice(msg) => {
botlog::notice(

View file

@ -16,8 +16,13 @@ pub type BotAR = Arc<RwLock<BotInstance>>;
pub async fn main() {
Log::set_file_ext(Extension::Log);
Log::set_level(Level::Trace);
Log::set_retention_days(2);
// Log::set_level(Level::Notice);
let bot = BotInstance::init().await;
{
@ -53,3 +58,6 @@ pub async fn main() {
let pstr = botlog::fatal("ERROR : EXIT Game loop", Some("main()".to_string()), None);
panic!("{}", pstr);
}