log retention = 2 days
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
This commit is contained in:
parent
7efb679b06
commit
7d8672913a
2 changed files with 24 additions and 0 deletions
|
@ -4,6 +4,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::sync::mpsc::UnboundedReceiver;
|
use tokio::sync::mpsc::UnboundedReceiver;
|
||||||
use tokio::sync::{Mutex, RwLock};
|
use tokio::sync::{Mutex, RwLock};
|
||||||
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
use twitch_irc::login::StaticLoginCredentials;
|
use twitch_irc::login::StaticLoginCredentials;
|
||||||
use twitch_irc::message::{PrivmsgMessage, ServerMessage};
|
use twitch_irc::message::{PrivmsgMessage, ServerMessage};
|
||||||
|
@ -23,6 +24,7 @@ use crate::core::identity::{ChangeResult, IdentityManager, Permissible};
|
||||||
use crate::core::botlog;
|
use crate::core::botlog;
|
||||||
use crate::core::chat::Chat;
|
use crate::core::chat::Chat;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
||||||
pub enum ChType {
|
pub enum ChType {
|
||||||
Channel(String),
|
Channel(String),
|
||||||
|
@ -109,6 +111,19 @@ impl BotInstance {
|
||||||
ratelimiters.insert(Channel(String::from(chnl)), n);
|
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 {
|
BotInstance {
|
||||||
prefix,
|
prefix,
|
||||||
bot_channel: Channel(login_name),
|
bot_channel: Channel(login_name),
|
||||||
|
@ -130,6 +145,7 @@ impl BotInstance {
|
||||||
let mut msglock = botlock.incoming_messages.write().await;
|
let mut msglock = botlock.incoming_messages.write().await;
|
||||||
|
|
||||||
while let Some(message) = msglock.recv().await {
|
while let Some(message) = msglock.recv().await {
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
ServerMessage::Notice(msg) => {
|
ServerMessage::Notice(msg) => {
|
||||||
botlog::notice(
|
botlog::notice(
|
||||||
|
|
|
@ -16,8 +16,13 @@ pub type BotAR = Arc<RwLock<BotInstance>>;
|
||||||
pub async fn main() {
|
pub async fn main() {
|
||||||
Log::set_file_ext(Extension::Log);
|
Log::set_file_ext(Extension::Log);
|
||||||
Log::set_level(Level::Trace);
|
Log::set_level(Level::Trace);
|
||||||
|
Log::set_retention_days(2);
|
||||||
// Log::set_level(Level::Notice);
|
// Log::set_level(Level::Notice);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let bot = BotInstance::init().await;
|
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);
|
let pstr = botlog::fatal("ERROR : EXIT Game loop", Some("main()".to_string()), None);
|
||||||
panic!("{}", pstr);
|
panic!("{}", pstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue