feat: add get clash logs from service

chore: log message
This commit is contained in:
oomeow
2025-10-12 23:54:48 +08:00
parent 19246ac616
commit 0e9595f255
5 changed files with 51 additions and 21 deletions

View File

@@ -5,15 +5,15 @@ use parking_lot::{RwLock, RwLockReadGuard};
const LOGS_QUEUE_LEN: usize = 100;
pub struct Logger {
pub struct ClashLogger {
logs: Arc<RwLock<VecDeque<String>>>,
}
impl Logger {
pub fn global() -> &'static Logger {
static LOGGER: OnceCell<Logger> = OnceCell::new();
impl ClashLogger {
pub fn global() -> &'static ClashLogger {
static LOGGER: OnceCell<ClashLogger> = OnceCell::new();
LOGGER.get_or_init(|| Logger {
LOGGER.get_or_init(|| ClashLogger {
logs: Arc::new(RwLock::new(VecDeque::with_capacity(LOGS_QUEUE_LEN + 10))),
})
}