Use the log create instead of println

This commit is contained in:
Slatian
2025-02-09 15:11:17 +01:00
parent 2aae2d6626
commit d902dae35d
6 changed files with 84 additions and 40 deletions

View File

@ -18,6 +18,7 @@ use governor::{
RateLimiter,
state::keyed::DefaultKeyedStateStore,
};
use log::debug;
use std::net::IpAddr;
use std::num::NonZeroU32;
@ -55,10 +56,10 @@ pub async fn rate_limit_middleware(
if limiter.check_key(&IpAddr::V4(std::net::Ipv4Addr::UNSPECIFIED)).is_ok() {
let oldlen = limiter.len();
if oldlen > 100 {
println!("Doing limiter cleanup ...");
debug!("Doing limiter cleanup ...");
limiter.retain_recent();
limiter.shrink_to_fit();
println!("Old limiter store size: {oldlen} New limiter store size: {}", limiter.len());
debug!("Old limiter store size: {oldlen} New limiter store size: {}", limiter.len());
}
}
next.run(req).await